diff --git a/assets/json/soundboard.json b/assets/json/soundboard.json index 28147a5d..f410d1c9 100644 --- a/assets/json/soundboard.json +++ b/assets/json/soundboard.json @@ -4,6 +4,7 @@ ["soundboard", "cat.mp3"], ["soundboard", "cow.mp3"], ["soundboard", "dun-dun-dun.mp3"], + ["explosion.mp3"], ["soundboard", "hello-there.mp3"], ["soundboard", "here-we-go-again.mp3"], ["jeopardy.mp3"], diff --git a/assets/sounds/explosion.mp3 b/assets/sounds/explosion.mp3 new file mode 100644 index 00000000..ceb5fa23 Binary files /dev/null and b/assets/sounds/explosion.mp3 differ diff --git a/commands/games-mp/mafia.js b/commands/games-mp/mafia.js index 01f4fec8..7b1b4aa0 100644 --- a/commands/games-mp/mafia.js +++ b/commands/games-mp/mafia.js @@ -22,6 +22,7 @@ module.exports = class MafiaCommand extends Command { const usage = this.client.registry.commands.get('join').usage(); return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`); } + if (this.client.dispatchers.has(msg.guild.id)) return msg.reply('I am already playing audio in this server.'); for (const member of connection.channel.members.values()) await msg.guild.members.fetch(member.id); if (connection.channel.members.size > 16) { return msg.reply('Please do not have more than 15 users in this voice channel.'); diff --git a/commands/games-sp/jeopardy.js b/commands/games-sp/jeopardy.js index aa819668..d90ad95d 100644 --- a/commands/games-sp/jeopardy.js +++ b/commands/games-sp/jeopardy.js @@ -45,8 +45,11 @@ module.exports = class JeopardyCommand extends Command { const question = await this.fetchQuestion(); const clueCard = await this.generateClueCard(question.question.replace(/<\/?i>/gi, '')); const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null; - if (connection) { - connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'jeopardy.mp3')); + if (msg.guild && connection && !this.client.dispatchers.has(msg.guild.id)) { + const dispatcher = connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'jeopardy.mp3')); + this.client.dispatchers.set(msg.guild.id, dispatcher); + dispatcher.once('finish', () => this.client.dispatchers.delete(msg.guild.id)); + dispatcher.once('error', () => this.client.dispatchers.delete(msg.guild.id)); await reactIfAble(msg, this.client.user, '๐Ÿ”‰'); } await msg.reply(`The category is: **${question.category.title.toUpperCase()}**. 30 seconds, good luck.`, { diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index 49d16278..4df4b36c 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -94,8 +94,13 @@ module.exports = class WhosThatPokemonCommand extends Command { const attachment = await this.createImage(data, true); const answerAttachment = await this.createImage(data, false); const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null; - if (connection) { - connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'whos-that-pokemon.mp3')); + if (msg.guild && connection && !this.client.dispatchers.has(msg.guild.id)) { + const dispatcher = connection.play( + path.join(__dirname, '..', '..', 'assets', 'sounds', 'whos-that-pokemon.mp3') + ); + this.client.dispatchers.set(msg.guild.id, dispatcher); + dispatcher.once('finish', () => this.client.dispatchers.delete(msg.guild.id)); + dispatcher.once('error', () => this.client.dispatchers.delete(msg.guild.id)); await reactIfAble(msg, this.client.user, '๐Ÿ”‰'); } await msg.reply('**You have 15 seconds, who\'s that Pokรฉmon?**', { files: [attachment] }); diff --git a/commands/roleplay/explode.js b/commands/roleplay/explode.js index 7938d5ce..3079bb52 100644 --- a/commands/roleplay/explode.js +++ b/commands/roleplay/explode.js @@ -11,6 +11,7 @@ module.exports = class ExplodeCommand extends ImgurAlbumCommand { description: 'Explodes a user.', clientPermissions: ['ATTACH_FILES'], albumID: EXPLODE_ALBUM_ID, + audio: 'explosion.mp3', args: [ { key: 'user', diff --git a/structures/commands/ImgurAlbum.js b/structures/commands/ImgurAlbum.js index 10cd730f..1ed3e02f 100644 --- a/structures/commands/ImgurAlbum.js +++ b/structures/commands/ImgurAlbum.js @@ -1,5 +1,7 @@ const request = require('node-superfetch'); const Command = require('../Command'); +const path = require('path'); +const { reactIfAble } = require('../../util/Util'); const { IMGUR_KEY } = process.env; module.exports = class ImgurAlbumCommand extends Command { @@ -14,11 +16,20 @@ module.exports = class ImgurAlbumCommand extends Command { reason: 'API', reasonURL: 'https://apidocs.imgur.com/' }); - this.noImage = info.noImage || false; + this.audio = info.audio || null; } async run(msg, { user }) { - if (this.noImage) return msg.say(this.generateText(msg, user)); + if (this.audio) { + const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null; + if (msg.guild && connection && !this.client.dispatchers.has(msg.guild.id)) { + const dispatcher = connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', this.audio)); + this.client.dispatchers.set(msg.guild.id, dispatcher); + dispatcher.once('finish', () => this.client.dispatchers.delete(msg.guild.id)); + dispatcher.once('error', () => this.client.dispatchers.delete(msg.guild.id)); + await reactIfAble(msg, this.client.user, '๐Ÿ”‰'); + } + } try { const image = await this.random(); if (!image) return msg.reply('This album has no images...');