admin管理员组文章数量:1296311
I am simply trying to make a bot join a voice channel as a placeholder so i can make a music bot play 24/7.
One of the codes that I found on stackoverflow was:
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
Do you know how I could solve this problem or tell me the right way to do this?
I am simply trying to make a bot join a voice channel as a placeholder so i can make a music bot play 24/7.
One of the codes that I found on stackoverflow was:
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
Do you know how I could solve this problem or tell me the right way to do this?
Share edited Dec 23, 2020 at 0:43 peterh 1 asked Jun 24, 2020 at 21:07 One Bass ManOne Bass Man 371 gold badge1 silver badge8 bronze badges 1-
1
Due to recent updates StackOverflow answers for discord.js are typically outdated. There's not much need to look at them anyway. The discord.js docs have plenty of examples and is very well put together. In this case you'd be wondering why
client.channels.get
isn't a function, so check the docs on client.channels and you'll see that it's now aChannelManager
and you need to access the cache property instead, as in Jakye's answer. – Klaycon Commented Jun 24, 2020 at 21:15
1 Answer
Reset to default 3Looks like you're using Discord.js V12. To get the channel you'll have to use:
client.channels.cache.get("ChannelID")
本文标签: javascriptHow do I make a discord bot join a voice channelStack Overflow
版权声明:本文标题:javascript - How do I make a discord bot join a voice channel? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741613809a2388413.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论