should fix the bot crash

this should fix the bot crash when the bot is disconnected because of voice channels is gone, or reconnecting to the voice channel but without any music, not tested yet
This commit is contained in:
Amane Serenetia 2025-01-04 02:39:32 +07:00
parent 68c9980703
commit 0bf035c71f

View File

@ -22,9 +22,9 @@ module.exports = async (client, oldState, newState) => {
if (oldState.channel.members.size === 1) {
setTimeout(() => {
// if 1 (you), wait 1 minute
if (!oldState.channel.members.size - 1) {
const player = client.musicManager.players.resolve(guild.id);
if (player) client.musicManager.getPlayer(guild.id).destroy(); // destroy the player
if (oldState.channel.members.size === 1) {
const player = client.musicManager.getPlayer(guild.id);
if (player) player.destroy(); // destroy the player
}
}, client.config.MUSIC.IDLE_TIME * 1000);
}