所以我试图为我的不和谐机器人发出抽奖命令。我有两个问题,我要根据谁对此消息的反应来使它成为赢家,这是我到目前为止所拥有的
const discord = require("discord.js")
const bot = new discord.Client();
module.exports.run = async (bot, message, args) => {
if (!message.member.hasPermission("MANAGE_CHANNELS")) return message.reply("sorry you dont have permission to use this command"); {
const embed = new discord.RichEmbed()
.setTitle('Raffle')
.addField('React to the message with a thumbs up to enter!', "Time for some fun!")
message.channel.send(embed).then(function (message) {
message.react('')
});
bot.on('messageReactionAdd', (reaction, user) => {
const user1 = reaction.random
const embed1 = new discord.RichEmbed()
.setTitle('Winner!!')
.addField(`${user1}`, "you are the winner!!")
message.channel.send(embed1);
});
}
}
module.exports.help = {
name: "Raffle",
name: "raffle"
}
所以user1会提前返回不确定的感谢,而且我对JavaScript还是半新的
答案 0 :(得分:1)
在您的代码中,将user1
设置为reaction.random
:
const user1 = reaction.random
reaction.random
不是MessageReaction
的有效方法,因此,在发送消息时,user1
是不确定的。