So I have giveaway embed with a reaction. After 10000 ms the giveaway ends and everything functions right. Now I want to stop the giveaway before 10000ms, because I added a 'giveaway end' command. And I have another question, if I have less reactions (without bot) than winners something like this happens: @x, @y, @z,,,,,(3 reactions and 7 winners). Can I cut that out?
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.channels.get(giveawayChannelid).fetchMessage(messageID)
.then(message => {
const filter = (reaction, user) => {
return reaction.emoji.name === '🎉' && user.id != bot.user.id;
};
message.awaitReactions(filter, {time: 10000, errors: ['time'] })
.catch(collected => {
const reaction = collected.first();
winnersEnd=reaction.users.filter((user) => !user.bot).random(winners);
});
});
You should use a global var, setting true when giveaways start, setting false when stop, and condition to lock, maybe in the filter callback?. also you should use a max setting in the option of message awaitReaction
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.