Javascript 向通道发送嵌入/消息时,返回未定义的
所以我有我为reactionrole设置编写的代码,我想让它转到“845711730809503744”,但返回的是未定义的。 完整代码:Javascript 向通道发送嵌入/消息时,返回未定义的,javascript,discord,discord.js,undefined,Javascript,Discord,Discord.js,Undefined,所以我有我为reactionrole设置编写的代码,我想让它转到“845711730809503744”,但返回的是未定义的。 完整代码: client.channels.cache.get(channel => channel.id === "845711730809503744").send(roleEmbed) 有人知道为什么以及如何解决此问题吗?首先,确保ID正确。那就试试看频道fetch从Discord或通道缓存(如果已经可用)获取通道 client.cha
client.channels.cache.get(channel => channel.id === "845711730809503744").send(roleEmbed)
有人知道为什么以及如何解决此问题吗?首先,确保ID正确。那就试试看频道
fetch
从Discord或通道缓存(如果已经可用)获取通道
client.channels
.fetch(“845711730809503744”)
.then(channel=>channel.send(roleEmbed))
.catch(console.error)
也可以使用异步/等待:
试试看{
const channel=wait client.channels.fetch(“845711730809503744”)
频道发送(roleEmbed)
}捕获(错误){
控制台错误(错误)
}
试试这个
const channel = client.channels.resolve('ID');
channel.send('ooh this is a message');
嗯,我尝试了“fetch”方法,结果返回:
HTTPError[DiscordjsError]:请求使用令牌,但令牌对客户端不可用。
,我认为这是“客户端”的问题?不确定代码的外观,但这需要在事件侦听器中。错误消息可能表示您试图在bot登录之前发出HTTP请求。
const channel = client.channels.resolve('ID');
channel.send('ooh this is a message');