I'm trying to make a custom teambuilder for my Discord channel. When a user reacts to a specific emoji, they would get placed in the specified team. The problem m getting is, idk how to grab the user id so I can store their userid/username in the team array to be displayed. I've tried going through the documentation but I don't think I completely understand the syntax. Here's a snippit of my code.
const {Client, Intents, MessageEmbed, GuildMember} = require("discord.js")
const client = new Client({ intents:[Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS] });
require('dotenv').config();
client.on("ready", () => {
console.log("Bot is online")
})
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.toLowerCase().startsWith('!formevent'))
{
console.log ("A message got sent")
let args = message.content.split(" ");
let scrimSize = args[1];
if (scrimSize == 10){
message.channel.send("Scrim size = "+ scrimSize)
const redSide = ['Test data for red team'];
const blueSide = ['Test data for blue team'];
redSide.length = 5;
blueSide.length = 5;
const embed = new MessageEmbed()
.setTitle ("Scrim")
.setDescription ("React with 💙 to join blue team.\n React with ❤️ to
join red team.")
const embed2 = new MessageEmbed()
.setTitle ("Blue Team (5 players)")
.setDescription (blueSide[0])
const embed3 = new MessageEmbed()
.setTitle ("Red Team (5 players)")
.setDescription (redSide[0])
let msg = await message.channel.send({embeds: [embed, embed2, embed3]})
await msg.react('💙');
await msg.react('❤️');
await msg.react('❌');
await msg.react('✅');
const filter =(reaction, user) =>
reaction.emoji.name === '💙' || reaction.emoji.name === '❤️' //&& user.id
=== '213832006486720512'
msg.awaitReactions({ filter, time: 5000})
.then (collected => console.log( `Collected ${collected.size}
reactions`))
.catch(console.error);
//console.log (GuildMember.Id);
//console.log(redSide[0]);
}