我尝试使用discord.js向Discord服务器中的特定通道发送消息,但当我尝试查找该通道时,它返回undefined。
我尝试过使用client.channels.get('ID').send("message")和client.channels.find('name', 'bot'),但都返回了undefined。
const duckHuntChannel = client.channels.get('ID').send("I'm a duck");
// Make some ducks
function sendDuck() {
if (huntStatus === true) {
duckHuntChannel.send("ducc")
setTimeout(sendDuck, Math.floor(Math.random() * 21) + 10);
} else {
console.log("I was gonna duck it up but I'm disabled :(");
}
}我希望输出只是向通道发送一条消息。我哪里弄错了?
发布于 2019-02-20 22:50:17
client.channels.get('ID')将返回一个通道。不要与Guildchannel混淆
根据您所在的事件,请尝试以下操作
message.guild.channels.get('ID')https://stackoverflow.com/questions/54727271
复制相似问题