我正在尝试使用ID向特定的频道发送消息,但输出无法读取未定义的属性“发送”

时间:2019-04-06 05:31:12

标签: javascript node.js bots discord discord.js

我有一条建议命令,我想发送到服务器中的特定频道。

if (!args) return message.channel.send("Please input a suggestion"); {
client.channels.get("563804889268879390").send({embed: {
color: 0x333333,
author: {
 name: "New suggestion!",
},
fields: [{
 name: "User",
 value: ${message.author.user}
},
{
 name: "Suggestion",
 value: args
},
]}})}    

我已将消息定义为client.on("message", async message => {。 即使我键入不带任何参数的命令,它也不会响应错误消息。当我尝试使用它时,它输出的只是(node:17876) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined。这些参数在其他命令上也能正常工作,所以我不知道问题可能出在哪里。

1 个答案:

答案 0 :(得分:1)

Cannot read property 'send' of undefined很可能意味着client.channels.get("563804889268879390")未定义,这意味着该通道的ID错误或Bot不在该通道所在的行会中。

确保ID有效!

相关问题