I search on Internet how can I do to get when the bot is kicked of a voice channel with the "Disconnect" button to send a message like "Bot disconnected of the voice channel" but I don't know how to get this information in discord.js I code a music bot with playlist but when i kick the bot of the vc and i do the !play command, it add the music to the queue and don't join the channel. I want clear the music queue with "queue.delete(guild.id)" whan the bot is kicked.
You Can Use Connection Disconnect Event, It Will Execute Code When Bot Get Disconnected From A Voice Channel
<Connection>.on("disconnect", () => {
console.log("Disconnected From Voice Channel!");
//...
});
Ex:
queue.connection.on("disconnect", () => {
console.log("disconnected from voice channel");
client.queue.delete(message.guild.id);
});
Links:
Voice Connection
Disconnect Event