【问题标题】:Type Error: message.createReactionCollector is not a function Discord.js类型错误:message.createReactionCollector 不是 Discord.js 函数
【发布时间】:2018-07-19 07:34:11
【问题描述】:

我正在为我的机器人制作一个赌博系统。我使用 discord.js 并尝试制作一个反应收集器来选择他们想玩的游戏。我想知道为什么创建反应收集器不是一个函数,所以也许它只是我。

代码如下:

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.

任何帮助将不胜感激! (如果有点乱,请见谅。)

【问题讨论】:

  • 您好,您能否发布完整的错误信息以帮助我们帮助您?谢谢!
  • 是的,我插入了完整的错误,没有太多可使用的......

标签: javascript node.js discord discord.js


【解决方案1】:

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

【讨论】:

  • 是的,问题是 m 变量无法通过下一个 .then,它可以在没有 .then 的情况下工作,但不能使其正常工作。我需要一个解决方案来让 m 变量传递第二个 .then (如果这有意义的话..)
  • 在第一个 .then 中返回 m - 您应该能够在第二个 .then 中获取变量
猜你喜欢
  • 2021-01-26
  • 2021-12-24
  • 2021-05-31
  • 2020-07-24
  • 2021-08-13
  • 2016-02-26
  • 2013-04-01
  • 2016-03-06
相关资源
最近更新 更多