mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Attempt Soundboard
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
const commando = require('discord.js-commando');
|
||||||
|
const sounds = require('./sounds.json');
|
||||||
|
|
||||||
|
class SoundBoardCommand extends commando.Command {
|
||||||
|
constructor(Client){
|
||||||
|
super(Client, {
|
||||||
|
name: 'soundboard',
|
||||||
|
group: 'random',
|
||||||
|
memberName: 'soundboard',
|
||||||
|
description: 'Plays a sound in your voice channel. (;soundboard cat)',
|
||||||
|
examples: [';soundboard cat']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(message, args) {
|
||||||
|
if(message.channel.type !== 'dm') {
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
|
||||||
|
}
|
||||||
|
console.log("[Command] " + message.content);
|
||||||
|
if(message.channel.type !== 'dm') {
|
||||||
|
if(!message.channel.permissionsFor(this.client.user).hasPermission('CONNECT' || 'SPEAK')) {
|
||||||
|
message.channel.send(':x: Error! In order to do this command, you must give me the permissions to "Connect" and "Speak"!');
|
||||||
|
} else {
|
||||||
|
let voiceChannel = message.member.voiceChannel;
|
||||||
|
if (!voiceChannel) {
|
||||||
|
return message.channel.send(`:x: Error! Please be in a voice channel first!`);
|
||||||
|
}
|
||||||
|
voiceChannel.join().then(connnection => {
|
||||||
|
let soundToPlay = message.content.toLowerCase().split(" ").slice(1).join(" ");
|
||||||
|
if(soundToPlay === "") {
|
||||||
|
message.channel.send(':x: Error! No sound set. Please use ;soundboard list to see a list of sounds you can play.');
|
||||||
|
} else if(soundToPlay === 'list') {
|
||||||
|
message.channel.send('**Avaliable Sounds:** Meow');
|
||||||
|
} else if(soundToPlay === sounds.avaliable[soundToPlay]) {
|
||||||
|
let stream = sounds.paths[soundToPlay];
|
||||||
|
let dispatcher = connnection.playStream(stream);
|
||||||
|
dispatcher.on('end', () => {
|
||||||
|
voiceChannel.leave();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
message.channel.send(':x: Error! Sound not found! Please use ;soundboard list to see a list of sounds you can play.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = SoundBoardCommand;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"avaliable": {
|
||||||
|
"meow": "meow"
|
||||||
|
}
|
||||||
|
"paths": {
|
||||||
|
"meow": "./sounds/cat.mp3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
"moment": "^2.17.1",
|
"moment": "^2.17.1",
|
||||||
"moment-duration-format": "^1.3.0",
|
"moment-duration-format": "^1.3.0",
|
||||||
"morse": "^0.1.0",
|
"morse": "^0.1.0",
|
||||||
|
"opusscript": "0.0.3",
|
||||||
"pirate-speak": "^1.0.1",
|
"pirate-speak": "^1.0.1",
|
||||||
"request-promise": "^4.1.1",
|
"request-promise": "^4.1.1",
|
||||||
"roman-numeral-converter-mmxvi": "^1.0.5",
|
"roman-numeral-converter-mmxvi": "^1.0.5",
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user