2020-02-05 20:02:53 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'skip',
|
|
|
|
alias: 's',
|
2020-02-24 18:41:40 +00:00
|
|
|
usage: '',
|
2020-02-05 20:02:53 +00:00
|
|
|
description: 'Skip the currently playing song.',
|
|
|
|
onlyDev: false,
|
|
|
|
permission: 'MANAGE_MESSAGES',
|
|
|
|
category: 'music',
|
|
|
|
execute(msg, args, client, Discord, prefix, command) {
|
2020-03-14 16:38:02 +00:00
|
|
|
const queue = client.queue.get(msg.guild.id);
|
2020-02-05 20:02:53 +00:00
|
|
|
const permissions = msg.channel.permissionsFor(msg.author);
|
2020-03-14 16:38:02 +00:00
|
|
|
if (!queue || !queue.playing) return msg.channel.send(client.messages.noServerQueue);
|
2020-02-05 20:02:53 +00:00
|
|
|
if (msg.author.id !== client.config.devId) {
|
2020-03-14 16:38:02 +00:00
|
|
|
if (msg.member.voice.channel !== queue.voiceChannel) return msg.channel.send(client.messages.wrongVoiceChannel);
|
2020-03-11 17:09:18 +00:00
|
|
|
if (client.global.db.guilds[msg.guild.id].permissions) {
|
|
|
|
if (!msg.member.roles.cache.has(client.global.db.guilds[msg.guild.id].djrole) || !permissions.has(command.permission)) {
|
2020-03-14 16:38:02 +00:00
|
|
|
return vote(queue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
} else {
|
2020-03-14 16:38:02 +00:00
|
|
|
return skipSong(queue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-14 16:38:02 +00:00
|
|
|
return skipSong(queue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-14 16:38:02 +00:00
|
|
|
return skipSong(queue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-03-14 16:38:02 +00:00
|
|
|
function skipSong(queue, msg, client) {
|
2020-03-12 11:56:31 +00:00
|
|
|
msg.channel.send(client.messages.skipped);
|
2020-03-14 16:38:02 +00:00
|
|
|
queue.endReason = "skip";
|
|
|
|
queue.connection.dispatcher.end();
|
2020-02-05 20:02:53 +00:00
|
|
|
};
|
2020-03-14 16:38:02 +00:00
|
|
|
function vote(queue, msg, client) {
|
|
|
|
queue.votesNeeded = Math.floor(queue.voiceChannel.members.size / 2);
|
|
|
|
queue.votesNeeded.toFixed();
|
|
|
|
if (queue.voiceChannel.members.size > 2) {
|
|
|
|
if (queue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
|
|
|
|
queue.votes++;
|
|
|
|
queue.voters.push(msg.member.id);
|
|
|
|
if (queue.votes >= queue.votesNeeded) {
|
|
|
|
queue.voters = [];
|
|
|
|
queue.votes = 0;
|
|
|
|
queue.votesNeeded = null;
|
|
|
|
return skipSong(queue, msg);
|
|
|
|
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${queue.votes} / ${queue.votesNeeded}!`);
|
2020-02-05 20:02:53 +00:00
|
|
|
} else {
|
2020-03-14 16:38:02 +00:00
|
|
|
return skipSong(queue, msg);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
};
|