【发布时间】:2020-10-15 05:55:23
【问题描述】:
我只是想让机器人作为占位符加入语音频道,这样我就可以让音乐机器人 24/7 播放。
我在堆栈overflow上找到的代码之一是:
const channel = client.channels.get("mychannelid");
if (!channel) return console.error("The channel does not exist!");
channel.join().then(connection => {
// Yay, it worked!
console.log("Successfully connected.");
}).catch(e => {
// Oh no, it errored! Let's log it to console :)
console.error(e);
});
});
but this didn't seem to work for me. This is what the visual studio code output said
你知道我该如何解决这个问题或告诉我正确的方法吗?
【问题讨论】:
-
由于最近的更新 StackOverflow 对 discord.js 的回答通常已经过时。反正也没必要看。 discord.js docs 有很多例子,并且很好地组合在一起。在这种情况下,您会想知道为什么
client.channels.get不是一个函数,所以检查docs on client.channels,您会发现它现在是ChannelManager,您需要访问缓存属性,如 Jakye 的回答.
标签: javascript bots discord discord.js voice