Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Fix: Bot tries to talk when it's alone
Browse files Browse the repository at this point in the history
  • Loading branch information
jftanner committed Oct 30, 2020
1 parent 031e1c8 commit 1757a3a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions classes/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1757a3a

Please sign in to comment.