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) {
|
|
|
|
const serverQueue = client.queue.get(msg.guild.id);
|
|
|
|
const permissions = msg.channel.permissionsFor(msg.author);
|
2020-03-12 11:56:31 +00:00
|
|
|
if (!serverQueue || !serverQueue.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-12 11:56:31 +00:00
|
|
|
if (msg.member.voice.channel !== serverQueue.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-02-05 20:02:53 +00:00
|
|
|
return vote(serverQueue, msg, client);
|
|
|
|
} else {
|
2020-03-12 11:56:31 +00:00
|
|
|
return skipSong(serverQueue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-12 11:56:31 +00:00
|
|
|
return skipSong(serverQueue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-12 11:56:31 +00:00
|
|
|
return skipSong(serverQueue, msg, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-03-12 11:56:31 +00:00
|
|
|
function skipSong(serverQueue, msg, client) {
|
|
|
|
msg.channel.send(client.messages.skipped);
|
2020-03-03 20:24:41 +00:00
|
|
|
serverQueue.endReason = "skip";
|
2020-03-04 21:17:33 +00:00
|
|
|
serverQueue.connection.dispatcher.end();
|
2020-02-05 20:02:53 +00:00
|
|
|
};
|
2020-03-12 11:56:31 +00:00
|
|
|
function vote(serverQueue, msg, client) {
|
2020-02-10 19:53:49 +00:00
|
|
|
serverQueue.votesNeeded = Math.floor(serverQueue.voiceChannel.members.size / 2);
|
2020-02-05 20:02:53 +00:00
|
|
|
serverQueue.votesNeeded.toFixed();
|
2020-02-10 19:56:43 +00:00
|
|
|
if (serverQueue.voiceChannel.members.size > 2) {
|
2020-03-12 11:56:31 +00:00
|
|
|
if (serverQueue.voters.includes(msg.member.id)) return msg.channel.send(client.messages.alreadyVoted);
|
2020-02-05 20:02:53 +00:00
|
|
|
serverQueue.votes++;
|
|
|
|
serverQueue.voters.push(msg.member.id);
|
|
|
|
if (serverQueue.votes >= serverQueue.votesNeeded) {
|
|
|
|
serverQueue.voters = [];
|
|
|
|
serverQueue.votes = 0;
|
|
|
|
serverQueue.votesNeeded = null;
|
|
|
|
return skipSong(serverQueue, msg);
|
2020-03-12 11:56:31 +00:00
|
|
|
} else return msg.channel.send(`${client.messages.notEnoughVotes} ${serverQueue.votes} / ${serverQueue.votesNeeded}!`);
|
2020-02-05 20:02:53 +00:00
|
|
|
} else {
|
|
|
|
return skipSong(serverQueue, msg);
|
|
|
|
}
|
|
|
|
};
|