gpt4 book ai didi

javascript - 我正在尝试使用 ID 向特定 channel 发送消息,但它输出 Cannot read property 'send' of undefined

转载 作者:行者123 更新时间:2023-12-02 23:53:18 24 4
gpt4 key购买 nike

我有一个建议命令,我想将其发送到服务器中的特定 channel 。

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。这些参数在我的其他命令上运行良好,所以我不知道问题是什么。

最佳答案

无法读取未定义的属性“send”很可能意味着client.channels.get("563804889268879390")未定义,这意味着 channel 的ID错误或者机器人不在 channel 所在的公会中。

确保ID有效!

关于javascript - 我正在尝试使用 ID 向特定 channel 发送消息,但它输出 Cannot read property 'send' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55546195/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com