diff --git a/AudioQueue.js b/AudioQueue.js index b981f02..dacda00 100644 --- a/AudioQueue.js +++ b/AudioQueue.js @@ -6,6 +6,7 @@ module.exports = class AudioQueue { this.api = api; this.queue = []; this.current = undefined; + this.api.player.on(Voice.AudioPlayerStatus.Idle, this.handleStop.bind(this)); } playNext() { if (this.queue.length == 0) { @@ -13,10 +14,8 @@ module.exports = class AudioQueue { return; } this.current = this.api.play(this.queue[0]); - this.api.player.on(Voice.AudioPlayerStatus.Idle, this.handleStop.bind(this)); } handleStop(current) { - console.log(`Handling stop`); this.queue.shift(); this.playNext(); } diff --git a/modules/announcer/index.js b/modules/announcer/index.js index 67be8cb..007b8ef 100644 --- a/modules/announcer/index.js +++ b/modules/announcer/index.js @@ -15,7 +15,7 @@ module.exports = function (bot, api) { if (!oldState.channel) { joined = true; let conn=api.getConnectionForVoiceChannel(channel); - api.queue=new AudioQueue(conn, api); + if (!api.queue) api.queue=new AudioQueue(conn, api); } let username = newState.member.displayName; diff --git a/modules/welcomer/index.js b/modules/welcomer/index.js index 6e0ed6d..85961bb 100644 --- a/modules/welcomer/index.js +++ b/modules/welcomer/index.js @@ -7,7 +7,7 @@ module.exports = function (bot, api) { const channel = await bot.channels.fetch(process.env.CHANNEL); await api.joinChannel(channel); let conn=api.getConnectionForVoiceChannel(channel); - api.queue=new AudioQueue(conn, api); + if (!api.queue) api.queue=new AudioQueue(conn, api); api.queue.add(__dirname + "/../../sysstart.wav"); api.speak(channel, api.strings.WELCOME); })