eximiabots-radiox/struct/funcs/check.js

13 lines
700 B
JavaScript
Raw Normal View History

2020-03-02 19:38:42 +00:00
module.exports = function (client, msg, command) {
const radio = client.radio.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author);
2020-03-12 00:50:05 +00:00
if (!radio || !radio.playing) return msg.channel.send('There is nothing playing!');
2020-03-02 19:38:42 +00:00
if (msg.author.id !== client.config.devId) {
2020-03-12 00:59:52 +00:00
if (msg.member.voice.channel !== radio.voiceChannel) return msg.channel.send(`You need to be in the same voice channel as RadioX to use this command!`);
2020-03-02 19:38:42 +00:00
if (!permissions.has(command.permission)) {
2020-03-12 00:50:05 +00:00
msg.channel.send(`You need the \`${command.permission}\` permission to use this command!`);
2020-03-02 19:38:42 +00:00
return false;
} else return true;
} else return true;
};