【发布时间】:2020-12-06 13:38:27
【问题描述】:
我正在尝试构建一个不和谐机器人,但我需要向特定频道发送消息。我已经尝试了 100 次,但不断得到:
TypeError: bot.channels.fetch(...).send is not a function.
在我阅读的所有地方,我都看到“使用 channel.send()”,但我找不到解决问题的实际方法。不推荐使用 channel.send() 吗?以下是错误引发错误的行:
bot.channels.fetch(id).send(message);
我知道 channels.get() 被贬低了,当使用 .fetch(id) 时,我得到了通道对象,但它不会让我发送消息。任何帮助都将不胜感激,因为我已经花了几天时间来解决这个问题。 谢谢。
完整的代码块:
var reportEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('New Report')
.setAuthor(msg.author.tag)
.setDescription(reportMessage)
.setTimestamp();
console.log(bot.channels.fetch('my channel id'));
bot.channels.fetch('my channel id').then(channel => {
channel.send(reportEmbed);
});
当控制台登录时,我得到了正确的通道对象。
【问题讨论】:
-
请展示更多您的代码。该代码块在哪个事件函数中?
标签: discord discord.js