mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 15:57:54 +02:00
The Power of const
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
const commando = require('discord.js-commando');
|
||||
const sounds = require('./sounds.json');
|
||||
const sounds = ['cat', 'pikachu', 'vader', 'doh', "it's a trap", 'mario death', 'pokemon center', 'dun dun dun', 'spongebob', 'ugly barnacle', 'woo hoo', 'space', 'glados bird', 'airhorn', 'zelda chest', 'eat my shorts', 'no this is patrick', 'wumbo'];
|
||||
const paths = {
|
||||
"cat": "./sounds/cat.mp3",
|
||||
"pikachu": "./sounds/pikachu.mp3",
|
||||
"vader": "./sounds/vader.mp3",
|
||||
"doh": "./sounds/doh.mp3",
|
||||
"it's a trap": "./sounds/its-a-trap.mp3",
|
||||
"mario death": "./sounds/mario-death.mp3",
|
||||
"pokemon center": "./sounds/pokemon-center.mp3",
|
||||
"dun dun dun": "./sounds/dun-dun-dun.mp3",
|
||||
"spongebob": "./sounds/spongebob.mp3",
|
||||
"ugly barnacle": "./sounds/ugly-barnacle.mp3",
|
||||
"woo hoo": "./sounds/woohoo.mp3",
|
||||
"space": "./sounds/space.mp3",
|
||||
"glados bird": "./sounds/glados-bird.mp3",
|
||||
"airhorn": "./sounds/airhorn.mp3",
|
||||
"zelda chest": "./sounds/zelda-chest.mp3",
|
||||
"eat my shorts": "./sounds/eat-my-shorts.mp3",
|
||||
"no this is patrick": "./sounds/no-this-is-patrick.mp3",
|
||||
"wumbo": "./sounds/wumbo.mp3"
|
||||
};
|
||||
|
||||
module.exports = class SoundBoardCommand extends commando.Command {
|
||||
constructor(Client) {
|
||||
@@ -20,7 +40,7 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
prompt: 'What sound do you want me to play?',
|
||||
type: 'string',
|
||||
validate: sound => {
|
||||
if (sounds.avaliable[sound.toLowerCase()]) {
|
||||
if (sounds.some(soundArray => sound.toLowerCase() === soundArray)) {
|
||||
return true;
|
||||
}
|
||||
return 'Sound not found. Use `;help soundboard` to view a list of sounds.';
|
||||
@@ -34,17 +54,17 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'CONNECT', 'SPEAK', 'ADD_REACTIONS'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let voiceChannel = message.member.voiceChannel;
|
||||
const voiceChannel = message.member.voiceChannel;
|
||||
if (!voiceChannel) return message.say(`:x: Error! Please be in a voice channel first!`);
|
||||
let soundToPlay = args.sound.toLowerCase();
|
||||
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
const soundToPlay = args.sound.toLowerCase();
|
||||
const alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
if (alreadyConnected) {
|
||||
if (alreadyConnected.channel.id === voiceChannel.id) return message.say(':x: Error! I am already playing a sound!');
|
||||
return message.say(':x: Error! I am already playing a sound!');
|
||||
}
|
||||
let connection = await voiceChannel.join();
|
||||
let stream = sounds.paths[soundToPlay];
|
||||
let dispatcher = connection.playStream(stream);
|
||||
const connection = await voiceChannel.join();
|
||||
const stream = paths[soundToPlay];
|
||||
const dispatcher = connection.playStream(stream);
|
||||
message.react('🔊');
|
||||
dispatcher.on('end', () => {
|
||||
message.react('✅');
|
||||
|
||||
Reference in New Issue
Block a user