How to make the bot leave a voice chat?

I have tried several options:
let connection = getVoiceConnection(interaction.guild.id);
if (connection === undefined) {
await interaction.reply("I am not in a vc!");
return;
};
connection.destroy();
let connection = getVoiceConnection(interaction.guild.id);
if (connection === undefined) {
await interaction.reply("I am not in a vc!");
return;
};
connection.destroy();
interaction.guild.members.me.voice.channel.leave()
interaction.guild.members.me.voice.channel.leave()
interaction.guild.member.voice.channel.leave()
interaction.guild.member.voice.channel.leave()
none working.
8 Replies
d.js toolkit
d.js toolkit•13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - ✅ Marked as resolved by OP
VLADY 🛡
VLADY 🛡OP•13mo ago
No description
dzlandis
dzlandis•13mo ago
connection.destroy() should make the bot leave the voice channel If it's not working, there is something else wrong with your code.
VLADY 🛡
VLADY 🛡OP•13mo ago
connection is undefined The bot is in the vc tho
dzlandis
dzlandis•13mo ago
Are you using the correct guildId when running getVoiceConnection()? Like are you running that command in the same guild as where the bot is connected to the voice channel?
VLADY 🛡
VLADY 🛡OP•13mo ago
Yeah ofc I'm not that dumb to run it elsewhere
Aman
Aman•13mo ago
it's me.voice.disconnect() That happens when there's a network interruption of any kind (e.g. restarting your bot without leaving the voice channel first, etc)
VLADY 🛡
VLADY 🛡OP•13mo ago
Thanks a lot Aman. I thought it's voice.channel.disconnect
Want results from more Discord servers?
Add your server