代码之家  ›  专栏  ›  技术社区  ›  Swoods23

类型错误:Message.CreateReactionCollector不是函数discord.js

  •  0
  • Swoods23  · 技术社区  · 8 年前

    我正在为我的机器人做一个赌博系统。我使用discord.js并试图让一个反应收集器来选择他们想要玩的游戏。idk为什么create a reaction collector不是函数,所以可能只有我一个人。

    代码如下:

    run(message) {
    
        const embed = new RichEmbed()
       .setColor(1)
       .setTitle(`Welcome to the gambling center! Please select a game to play!`)
       .addBlankField(true)
       .addField(`:one:`, `Gamble away to win double or nothin!`)
       .addBlankField(true)
       .addField(`:two:`, `Gamble like the lottery to have a chance to win big!`)
       .addBlankField(true)
       let m = message.channel.send({embed}).then((m)=>{
            m.react('\u0031\u20E3')
            m.react('\u0032\u20E3')
        }).then(()=>{
            const collector = message.createReactionCollector((reaction, user) => 
                user.id === message.author.id &&
                reaction.emoji.name === "\u0031\u20E3" ||
                reaction.emoji.name === "\u0032\u20E3" 
            ).once("collect", reaction => {
                 const chosen = reaction.emoji.name;
                     if(chosen === "\u0031\u20E3"){
                        message.channel.send(`Double or Nothin!`)
                    }else{(chosen === "\u0032\u20E3")
                    message.channel.send(`Lottery!`)}
    collector.stop()});
        })  
    }
    

    下面是弹出的完整错误:

    (node:5948) UnhandledPromiseRejectionWarning: TypeError: message.createReactionCollector is not a function
    at message.channel.send.then.then (C:\Users\patri\Documents\Super Dev\commands\Economy\Gamble.js:36:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
    (node:5948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:5948) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    任何帮助都将不胜感激!(如果有点乱,很抱歉。)

    1 回复  |  直到 8 年前
        1
  •  0
  •   Saddy    8 年前

    似乎您正在发送消息,但使用了不同的消息对象。尝试将变量m设为反应收集器