My bot sends a message when a new member is added to the guild. The message goes to a specific user.
client.on('guildMemberAdd', member => {
const adminDm = client.users.cache.get(Config.get('ADMIN'));
client.commands.get('novoMembro').execute(member, adminDm);
});
Now I need to collect the reaction in order to assign some role to the new member.
const Discord = require('discord.js');
module.exports = {
name: 'novoMembro',
description: "Adding a new member to the guild",
execute(member, adminDm){
const novoMembroEmbed = new Discord.MessageEmbed()
.setColor([153,0,76])
.setTitle('NOVO MEMBRO ADICIONADO')
.setDescription(`<@!${member.id}> foi adicionado`)
.addFields(
{name: 'Selecione uma opção:', value: 'Reaja com para enviar mensagem de boas vindas \n Reaja com ❌ para cancelar'},
);
adminDm.send({ embeds: [novoMembroEmbed] }).then((msg => {
msg.react('❌');
msg.react('');
}));
}
}
Until this point, the code works fine. But I can't find a way to collect the reactions, every code I've tried doesn't work. I think I didn't understand right the concept of collecting reactions. these are some code I've tried.
const filter = (reaction) => ['❌', ''].includes(reaction.emoji.name);
const reactOptions = {maxEmojis: 1};
.then(() => msg.awaitReactions(filter, reactOptions)).then(collected => {
if (collected.first().emoji.name === '') {
console.log('msg de boas vindas');
}else{
console.log('cancelando');
}
