diff --git a/modules/announcer/index.js b/modules/announcer/index.js index 007b8ef..847f003 100644 --- a/modules/announcer/index.js +++ b/modules/announcer/index.js @@ -1,5 +1,5 @@ -const printf=require('printf'); -const AudioQueue=require('../../AudioQueue.js') +const printf = require('printf'); +const AudioQueue = require('../../AudioQueue.js') module.exports = function (bot, api) { bot.on('voiceStateUpdate', async (oldState, newState) => { @@ -8,14 +8,15 @@ module.exports = function (bot, api) { const channel = oldState.channel || newState.channel; if (!channel) return; if (channel.members.size < 2) { - return await api.leaveChannel(channel); + await api.leaveChannel(channel); + api.AudioQueue.flush(); } await api.joinChannel(channel); let joined = false; if (!oldState.channel) { joined = true; - let conn=api.getConnectionForVoiceChannel(channel); - if (!api.queue) api.queue=new AudioQueue(conn, api); + let conn = api.getConnectionForVoiceChannel(channel); + if (!api.queue) api.queue = new AudioQueue(conn, api); } let username = newState.member.displayName;