diff --git a/CHANGELOG.md b/CHANGELOG.md index 68767dc7..638e258b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -## 0.6.0 (2017-02-26) +## 0.7.0 (2017-02-27) + ++ Added possibility to delete `!` messages after playthrough. + +## 0.6.0 (2017-02-27) + Made accepted file formats configurable. ([`#3`](https://github.com/markokajzer/discord-soundbot/issues/3)) + Made accepted file size configurable. diff --git a/README.md b/README.md index c4aad324..126a26f6 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,12 @@ All sounds will be added to a queue and played in succession. To halt the playba ### Removing sounds You can delete sounds by typing `!remove `. The bot will respond with the status of the deletion in the channel of the message. + + +## Configuration + +You can configure the accepted file formats (via the `extensions` array) as well as the size of the accepted files (via the `size` given in bytes). + +The bot can also automatically delete `!` messages for you to reduce channel spam. For this, set `deleteMessages` to `true`. + +Check `config/default-example.json` for an example config. diff --git a/config/default-example.json b/config/default-example.json index fd944ffc..0a2721c5 100644 --- a/config/default-example.json +++ b/config/default-example.json @@ -2,5 +2,6 @@ "client_id": "YOUR_CLIENT/APPLICATION_ID", "token": "YOUR_APP_BOT_USER_TOKEN", "extensions": [".mp3", ".wav"], - "size": 1000000 + "size": 1000000, + "deleteMessages": false } diff --git a/package.json b/package.json index 12f269bf..c533dd7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dicord_soundbot", - "version": "0.6.0", + "version": "0.7.0", "description": "A Discord Bot to play sounds", "main": "bot.js", "dependencies": { diff --git a/src/MessageHandler.js b/src/MessageHandler.js index c4f3b635..23640c67 100644 --- a/src/MessageHandler.js +++ b/src/MessageHandler.js @@ -31,11 +31,11 @@ class MessageHandler { this.bot.queue = []; } else if (message.content === '!random') { const random = sounds[Math.floor(Math.random() * sounds.length)]; - this.bot.addToQueue(voiceChannel, random); + this.bot.addToQueue(voiceChannel.id, random, message); } else { const sound = message.content.split('!')[1]; if (sounds.includes(sound)) { - this.bot.addToQueue(voiceChannel, sound); + this.bot.addToQueue(voiceChannel.id, sound, message); if (this.bot.voiceConnections.array().length === 0) this.bot.playSoundQueue(); } } diff --git a/src/SoundBot.js b/src/SoundBot.js index 5c98e7ec..30ada075 100644 --- a/src/SoundBot.js +++ b/src/SoundBot.js @@ -28,8 +28,8 @@ class SoundBot extends Discord.Client { this.messageHandler.handle(message); } - addToQueue(voiceChannel, sound) { - this.queue.push({ name: sound, channel: voiceChannel.id }); + addToQueue(voiceChannel, sound, messageTrigger) { + this.queue.push({ name: sound, channel: voiceChannel, message: messageTrigger }); } playSoundQueue() { @@ -41,6 +41,8 @@ class SoundBot extends Discord.Client { const dispatcher = connection.playFile(file); dispatcher.on('end', () => { Util.updateCount(nextSound.name); + if (config.get('deleteMessages') === true) + nextSound.message.delete(); if (this.queue.length > 0) this.playSoundQueue();