From 4c5dcea757801652be2385a3c463e5fc8da4e226 Mon Sep 17 00:00:00 2001 From: markokajzer Date: Wed, 20 Dec 2017 10:26:45 +0100 Subject: [PATCH] Added stayInChannel configuration option --- CHANGELOG.md | 4 ++++ README.md | 2 ++ config/default-example.json | 3 ++- src/SoundBot.js | 4 ++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d67781a0..96630ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.0 (2017-12-20) + ++ Added `stayInChannel` configuration option + ## 0.10.0 (2017-09-11) + Added prefix configuration diff --git a/README.md b/README.md index c97c9956..efa93af3 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,6 @@ The bot can also automatically delete `!` 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. diff --git a/config/default-example.json b/config/default-example.json index 7ff6cb0a..0152c6df 100644 --- a/config/default-example.json +++ b/config/default-example.json @@ -4,5 +4,6 @@ "prefix": "!", "extensions": [".mp3", ".wav"], "size": 1000000, - "deleteMessages": false + "deleteMessages": false, + "stayInChannel": false } diff --git a/src/SoundBot.js b/src/SoundBot.js index 6984911c..6168bebe 100644 --- a/src/SoundBot.js +++ b/src/SoundBot.js @@ -100,7 +100,7 @@ class SoundBot extends Discord.Client { } _currentlyPlaying() { - return this.voiceConnections.array().length > 0; + return this.voiceConnections.some(connection => connection.speaking); } playSoundQueue() { @@ -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; }