有没有办法将 discord.js 消息发送到特定频道?

时间:2021-03-21 20:35:08

标签: javascript node.js discord discord.js

我找到了这个,但它不起作用并说发送未定义。有人知道为什么吗?

client.channels.cache.get("channelidwashere").send(sellembed1)

1 个答案:

答案 0 :(得分:1)

如果我没记错的话,您尝试发送消息的方式已经过时

试试这个:

const channel = await client.channels.fetch('youridhere');
await channel.send(embed1);

编辑:我从这里的文档中得到它:https://discord.js.org/#/docs/main/stable/class/ChannelManager client.channels 返回一个 ChannelManager,因此您应该能够调用您在此页面上找到的方法。