首页 > 解决方案 > 有没有办法将 discord.js 消息发送到特定频道?

问题描述

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

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

标签: javascriptnode.jsdiscorddiscord.js

解决方案


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

尝试这个:

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

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


推荐阅读