I want the discord.js bot to send a message when a mand is executed, react on it and then catch all reactions from users to do certain stuff, like respond to them. No time limit should be applied to reactions. I should also mention that I'm using a mand handler and the message is being sent from another file than index.js (in which the collect even should occur).
I tried doing a collector but no matter how I do it, the collector variable is not defined or not working. I know it should be a collector for a fact though.
Making a filter for the checkmark emoji:
return reaction.emoji.name === `✅` && user.id === call.message.author.id;
}
Trying to catch reactions outside the mand block itself (because if I do it IN the block the event won't work:
collector.on(`collect`, (reaction, reactionCollector) => {
console.log(`Caught ${reaction.emoji.name}`);
});
The errors I get are pretty much expected but I want to solve that:
collector.on(`collect`, (reaction, reactionCollector) => {
^
ReferenceError: collector is not defined
Maybe a global variable or setting the message id and then fetching? Help me.
I want the discord.js bot to send a message when a mand is executed, react on it and then catch all reactions from users to do certain stuff, like respond to them. No time limit should be applied to reactions. I should also mention that I'm using a mand handler and the message is being sent from another file than index.js (in which the collect even should occur).
I tried doing a collector but no matter how I do it, the collector variable is not defined or not working. I know it should be a collector for a fact though.
Making a filter for the checkmark emoji:
return reaction.emoji.name === `✅` && user.id === call.message.author.id;
}
Trying to catch reactions outside the mand block itself (because if I do it IN the block the event won't work:
collector.on(`collect`, (reaction, reactionCollector) => {
console.log(`Caught ${reaction.emoji.name}`);
});
The errors I get are pretty much expected but I want to solve that:
collector.on(`collect`, (reaction, reactionCollector) => {
^
ReferenceError: collector is not defined
Maybe a global variable or setting the message id and then fetching? Help me.
Share Improve this question asked Aug 11, 2019 at 17:16 NorteXNorteX 451 gold badge3 silver badges7 bronze badges 1- There's a Discord.js guide: awaiting reactions / reaction collectors – JackRed Commented Aug 11, 2019 at 21:03
1 Answer
Reset to default 6Why not include the Collector in your mand.js?
const time = 60000 //amount of time to collect for in milliseconds
receivedMessage.channel.send("Hello World")
.then(async function (message) {
await message.react('✅')
const filter = (reaction, user) => {
return //YOUR FILTER HERE;
};
const collector = message.createReactionCollector(filter, { time: time });
collector.on('collect', (reaction, reactionCollector) => {
//do stuff
});
});