我有一条建议命令,我想发送到服务器中的特定频道。
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
。这些参数在其他命令上也能正常工作,所以我不知道问题可能出在哪里。
答案 0 :(得分:1)
Cannot read property 'send' of undefined
很可能意味着client.channels.get("563804889268879390")
未定义,这意味着该通道的ID错误或Bot不在该通道所在的行会中。
确保ID有效!