Javascript 试图为我的discord bot发出抽奖命令,但始终返回未定义的获胜者
所以我想为我的discord机器人发一张奖券。我有两个问题,我想让它成为一个赢家,根据谁对这条信息的反应,这就是我到目前为止得到的Javascript 试图为我的discord bot发出抽奖命令,但始终返回未定义的获胜者,javascript,discord,discord.js,Javascript,Discord,Discord.js,所以我想为我的discord机器人发一张奖券。我有两个问题,我想让它成为一个赢家,根据谁对这条信息的反应,这就是我到目前为止得到的 const discord = require("discord.js") const bot = new discord.Client(); module.exports.run = async (bot, message, args) => { if (!message.member.hasPermission("MANAGE_CHANNELS"
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('In your code, you set user1
to reaction.random
:
const user1 = reaction.random
const discord=require(“discord.js”)
const bot=new discord.Client();
module.exports.run=async(bot、消息、args)=>{
if(!message.member.hasPermission(“管理频道”))返回message.reply(“抱歉,您没有使用此命令的权限”){
const embed=new discord.RichEmbed()
.setTitle(“抽奖”)
.addField('竖起大拇指响应消息以进入!',“是时候找点乐子了!”)
message.channel.send(嵌入).then(函数(消息){
message.react(“在代码中,您将user1
设置为reaction.random
:
reaction.random
不是一种有效的方法,因此,当您发送消息时,user1
是未定义的。如何获得对消息做出反应的随机用户?我也尝试了reaction.users,但它仍然返回未定义。我根本不会使用messageReactionAdd
。这是用户添加reaction的时候n到消息。您打算如何选择赢家?添加反应不应导致选择赢家。我会使用命令,如!winner
,在做出所有反应后,您应该检查该命令。然后您可以获取,并获得所有反应。用于查找消息。(将ID存储在某个位置)