I'm trying to get my first discord bot to send a message after clicking a reaction,
One for yes reaction, one for no
I have my code already send an embed with the reactions
I created a Reaction collector but the only thing now its that it instantly reacts with (reacted no) twice, even before I click the reaction
Help is greatly appreciated!
My Code so far:
const {Client, RichEmbed } = require('discord.js');
const client = new Client();
const a =
client.once('ready', () => {
console.log('boogie time!');
});
client.on('message', message => {
if(message.author.bot)
{
if(message.embeds)
{
const embedMsg = message.embeds.find(msg=> msg.title ==='Boogie Time!?');
if(embedMsg)
{
embedMsg.message.react('✅')
.then(reaction => reaction.message.react('❌'))
// This is filter, this specified which reactions it should capture, you can use filter to make sure you're only catching specific reactions by specific user
const filter = (reaction, user) => (reaction.emoji.name === '✅' || reaction.emoji.name === '❌') && user.id === message.author.id;
// Here, we're defining a collector that will be active for 30 seconds and collect reactions that pass the above filter
const collector = embedMsg.message.createReactionCollector(filter, {time: 10000});
// This event is emitted when a reaction passes through the filter
collector.on('collect', r => r.name === '✅' ?
console.log('Reacted Yes') : console.log('Reacted No'));
}
}
return;
}
if(message.content.toLowerCase() === 'boogie')
{
const embed = new RichEmbed();
embed.setTitle("Boogie Time!?")
embed.setColor("GREEN")
embed.setDescription("Are you sure?")
message.channel.send(embed);
};
});