Skip to content

Commit

Permalink
Added stayInChannel configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
markokajzer committed Dec 20, 2017
1 parent fe61878 commit 4c5dcea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.0 (2017-12-20)

+ Added `stayInChannel` configuration option

## 0.10.0 (2017-09-11)

+ Added prefix configuration
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ The bot can also automatically delete `!<sound>` messages for you to reduce chan

To add an avatar to your bot, add a file called `avatar.png` to the `config/` folder and restart the bot. To remove the avatar, delete `avatar.png` and restart the bot.

To let the bot stay in the channel after playing sounds to reduce noise, you can set the `stayInChannel` configuration option.

Check `config/default-example.json` for an example config and create a new file `default.json` with your desired configuration inside the `config` folder.
3 changes: 2 additions & 1 deletion config/default-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"prefix": "!",
"extensions": [".mp3", ".wav"],
"size": 1000000,
"deleteMessages": false
"deleteMessages": false,
"stayInChannel": false
}
4 changes: 2 additions & 2 deletions src/SoundBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SoundBot extends Discord.Client {
}

_currentlyPlaying() {
return this.voiceConnections.array().length > 0;
return this.voiceConnections.some(connection => connection.speaking);
}

playSoundQueue() {
Expand All @@ -115,7 +115,7 @@ class SoundBot extends Discord.Client {
if (config.get('deleteMessages') === true) nextSound.message.delete();

if (this.queue.length === 0) {
connection.disconnect();
if (!config.get('stayInChannel')) connection.disconnect();
return;
}

Expand Down

0 comments on commit 4c5dcea

Please sign in to comment.