【问题标题】:dmChannel is not working and is returning nulldmChannel 不工作并返回 null
【发布时间】:2021-03-30 21:07:24
【问题描述】:

我有问题。机器人不想从消息中的作者对象获取dmChannel。 dmChannel 始终为null。这是我的代码:

    if (command === "suggest") {
  message.channel.send("**Please, revise the DM that I sent you.**");
  let msg = message.author.send("Please, state a valid suggestion. Max time: 3 mins. If you want to cancel, say `cancel`.");
  let filter = m => m.content.includes('');
  msg.channel.awaitMessages(filter, { max: 1, time: 180000, errors: ['time'] })
  .then(collected => {
    if (collected.content.toLowerCase() === "cancel") {return;}
    client.channels.cache.get('790403704171659274').send(new MessageEmbed().setTitle("New Suggestion!").setColor("c0ed8c").setDescription(package.description).setFooter("Made by " + message.author.toString(), client.user.avatarURL()).setTimestamp().addField("Suggestion", collected.content));
  })
  .catch(collected => {
    if(collected.size === 0) {message.author.send("Prompt cancelled."); return;}
    message.author.send("Thanks for making your suggestions! They are all apreciated.")
  });
}

谢谢!!!

【问题讨论】:

  • 它告诉你错误发生在哪一行?

标签: javascript discord discord.js


【解决方案1】:

我认为这是一个问题,因为您不需要等待几件事情,我做了完全相同的事情并且效果很好。

msg,试试let msg = await message.author.send('your message')

msg.channel.awaitMessages() 试试await msg.channel.awaitMessage

我可能是错的,但正如我之前所说,我在 DM 频道中做同样的事情并且效果很好。

【讨论】:

  • 嗨!谢谢你帮助我。一样的。我得到了相同的结果:null。后来我也试过了。有什么想法吗?
猜你喜欢
  • 2018-08-26
  • 2013-08-10
  • 1970-01-01
  • 2022-08-11
  • 1970-01-01
  • 2020-01-20
  • 1970-01-01
  • 2021-06-30
  • 2015-10-25
相关资源
最近更新 更多