admin管理员组文章数量:1356941
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
});
});
本文标签: javascriptDiscordjs How to send a message and collect reactions from itStack Overflow
版权声明:本文标题:javascript - Discord.js: How to send a message and collect reactions from it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743973431a2570783.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论