Discord.VoiceConnection.disconnect();
This is the current code, but I have used
message.member.voice.channel.disconnect() message.member.voice.channel.leave() message.member.voiceChannel.disconnect() message.member.voiceConnection.leave() message.member.voiceChannel.leave()...etc.
The reason I use VoiceConnection.disconnect() is my older function connection.disconnect();
works and the bot leaves.
I tracked where connection
came from and the result was from VoiceConnection and from there
I tried using Discord.VoiceConnection
. But still the bot doesn't wan't do leave. I am currently using v12. Can anybody help?
Try using
message.guild.me.voice.channel.leave();
message.guild.me is the Bot's Member Object in this guild, and so you get the channel and can leave it.
If you are using the normal discord.js package for voice
message.guild.me.voice.channel.leave()
should work. Here are you looking for the voice channel where the bot is currently in and you leave it.
If you are using the @discordjs/voice package for voice you should use
const voice = require('@discordjs/voice');
voice.getVoiceConnection(`guild_id`).disconnect();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.