Im trying to make an _soundboard / _sb command and i try to check if the .mp3 file exists or not but for any reason it won't work. I hope someone can help me with that..
const Discord = require('discord.js');
const fs = require('fs');
module.exports.run = (client, message, args) => {
if(message.author.id !== '201679157124399104') {
message.channel.send(`Nope this is a testing command!`)
return;
};
if(!message.member.voiceChannel) {
message.channel.send(`You need to be in a voicechannel to do this!`)
return;
};
let sound = args[0] + ".mp3";
if(fs.exists(`./sounds/${sound}`,function(exists){})) {
let vc = message.member.voiceChannel
vc.join().then(connection => {
const dispatcher = connection.playFile(`./sounds/${sound}`);
message.channel.send(`playing: ${sound}`).then(m => m.delete(10000))
dispatcher.on('end', () => {
vc.leave();
})
return;
});
}
message.channel.send(`The sound "${sound}" doesn't exists!`)
};
module.exports.help = {
name: "soundboard",
name2: "sb"
};