From 1757a3a8138a65b0d13f773b1a419bd06deea0d2 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 30 Oct 2020 01:50:03 -0400 Subject: [PATCH] Fix: Bot tries to talk when it's alone --- classes/Lobby.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/Lobby.js b/classes/Lobby.js index 5777bd5..220bfcd 100644 --- a/classes/Lobby.js +++ b/classes/Lobby.js @@ -622,7 +622,7 @@ class Lobby { // End the lobby if there are no more connected players. const gameIsInMenu = this.phase === PHASE.MENU; const gameHasNoGuildMembers = this.players.every(player => !player.guildMember); - const channelIsEmpty = !this.voiceChannel.members.first(); + const channelIsEmpty = this.voiceChannel.members.array().every(member => member?.user?.bot); if (gameHasNoGuildMembers || (channelIsEmpty && gameIsInMenu)) { await this.stop("All the Discord users left, so I ended the lobby."); } @@ -930,7 +930,10 @@ class Lobby { this.stopped = true; // Announce to users, then leave the channel. - await this.speak('see-you-later', () => {this.voiceChannel.leave();}); + if (this.voiceChannel.members.array().some(member => !member?.user?.bot)) { + await this.speak('see-you-later', () => {this.voiceChannel.leave();}); + } + else this.voiceChannel.leave(); // Unlink the maps. lobbiesByVoiceChannel.delete(this.voiceChannel.id);