mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 16:19:12 +02:00
Soundboard Command is Back
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const path = require('path');
|
||||
const sounds = require('../../assets/json/soundboard');
|
||||
|
||||
module.exports = class SoundboardCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'soundboard',
|
||||
aliases: ['sound'],
|
||||
group: 'voice',
|
||||
memberName: 'soundboard',
|
||||
description: 'Plays a sound in a voice channel.',
|
||||
guildOnly: true,
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
userPermissions: ['CONNECT', 'SPEAK'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Pokémon',
|
||||
url: 'https://www.pokemon.com/us/',
|
||||
reason: 'Pikachu Sound'
|
||||
},
|
||||
{
|
||||
name: '07th Expansion',
|
||||
url: 'http://07th-expansion.net/',
|
||||
reason: 'Nipah Sound'
|
||||
},
|
||||
{
|
||||
name: 'Re:ZERO -Starting Life in Another World-',
|
||||
url: 'http://re-zero-anime.jp/',
|
||||
reason: 'Subaru Ringtone Sound'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'sound',
|
||||
prompt: `What sound do you want to play? Either ${list(sounds, 'or')}.`,
|
||||
type: 'string',
|
||||
default: () => `${sounds[Math.floor(Math.random() * sounds.length)]}.mp3`,
|
||||
oneOf: sounds,
|
||||
parse: sound => `${sound.toLowerCase()}.mp3`
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { sound }) {
|
||||
const inGuild = msg.guild ? undefined : null;
|
||||
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||
if (!connection) {
|
||||
return msg.reply(`I am not in a voice channel. Use ${msg.anyUsage('join', inGuild, inGuild)} to fix that!`);
|
||||
}
|
||||
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'soundboard', sound));
|
||||
if (msg.channel.permissionsFor(this.client.user).has(['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'])) {
|
||||
await msg.react('🔉');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user