javascript - 在 Direct Message Discord js 中等待来自用户的消息

标签 javascript discord.js

我试图让我的机器人等待直接消息(在本例中是某个名称),然后将其写回到直接消息中的同一用户(在本例中是我)。

我尝试使用message.author.awaitMessages但控制台返回:

TypeError: message.author.awaitResponse is not a function

message.author.send('Write your Name')
      .then(function(){
        message.channel.awaitMessages(response => message.content, {
          max: 1,
          time: 300000000,
          errors: ['time'],
        })
        .then((collected) => {
            message.author.send(`Your Name is: ${collected.first().content}`);
          })
          .catch(function(){
            message.channel.send('You didnt write your name');
          });
      });
  }

最佳答案

尝试message.author.dmChannel.awaitMessages

查看文档中的更多信息 https://discord.js.org/#/docs/main/stable/class/User?scrollTo=dmChannel

关于javascript - 在 Direct Message Discord js 中等待来自用户的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47722608/

相关文章:

javascript - 如何将 JSON 值从 Controller 传递到 Thymeleaf 中的 HTML?

javascript - 根据输入改变图像

javascript - Node.js - 迭代运行带有回调的函数

javascript - 改变 HTML 元素的可见性

javascript - 我多久可以重命名一次不和谐 channel 的名称?

javascript - 从提交的图像中获取 URL

javascript - Discord.js 的 EventEmitter Javascript 限制问题

javascript - Stripe webhooks 事件顺序

javascript - 类型错误 : Cannot read properties of undefined (reading 'guild' )

javascript - Discord 机器人的特定角色命令