首页 > 解决方案 > message.author.dmChannel.awaitMessages 不起作用

问题描述

我有一个设置命令,设置发生在 DM 中。发送第一条消息有效,但每当我 dm 机器人时,它都不会检测到我的消息。代码:

const filter = m => m.content;
message.author.dmChannel.awaitMessages(filter, {
  max: 1,
  time: 60000,
  errors: ["time"]
}).then(collected => {
  collected.reply("message collected message");
}.catch(() => message.author.send("ran out of time message")

当时间用完时,它会向我发送时间用完消息

我也试过这个,但也没有用

const filter = m => m.content;
message.author.dmChannel.awaitMessages({
  filter,
  max: 1,
  time: 60000,
  errors: ["time"]
}).then(collected => {
  collected.reply("message collected message");
}.catch(() => message.author.send("ran out of time message")

标签: javascriptdiscord.js

解决方案


TextChannel.awaitMessages()现在只需要 1 个参数。这包括对象中的过滤器属性。将其更改为此将起作用:

const filter = m => m.content;
message.author.dmChannel.awaitMessages({
  filter,
  max: 1,
  time: 60000,
  errors: ["time"]
})

推荐阅读