mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 02:00:20 +00:00
Voteskip
This commit is contained in:
parent
c32d592074
commit
698bb0eb9b
@ -29,7 +29,10 @@ module.exports = {
|
||||
songs: [...songs],
|
||||
volume: client.global.db.guilds[message.guild.id].defaultVolume,
|
||||
playing: true,
|
||||
looping: false
|
||||
looping: false,
|
||||
votes: 0,
|
||||
voters: [],
|
||||
votesNeeded: null
|
||||
};
|
||||
client.queue.set(message.guild.id, construct);
|
||||
message.channel.send(":white_check_mark: Queue set!");
|
||||
|
@ -12,12 +12,37 @@ module.exports = {
|
||||
if (message.author.id !== client.config.dev) {
|
||||
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voice channel as Musix to skip the song!');
|
||||
if (client.global.db.guilds[message.guild.id].permissions === true) {
|
||||
if (client.global.db.guilds[message.guild.id].dj) {
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole)) return message.channel.send(':x: You need the `DJ` role to skip songs!');
|
||||
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!');
|
||||
if (!message.member.roles.has(client.global.db.guilds[message.guild.id].djrole) && !permissions.has('MANAGE_MESSAGES')) {
|
||||
return vote(serverQueue, message, client);
|
||||
} else {
|
||||
return skipSong(serverQueue, message);
|
||||
}
|
||||
} else {
|
||||
return vote(serverQueue, message, client);
|
||||
}
|
||||
} else {
|
||||
return skipSong(serverQueue, message);
|
||||
}
|
||||
message.channel.send(':fast_forward: Skipped the song!');
|
||||
serverQueue.connection.dispatcher.end('skipped');
|
||||
}
|
||||
};
|
||||
function skipSong(serverQueue, message) {
|
||||
message.channel.send(':fast_forward: Skipped the song!');
|
||||
serverQueue.connection.dispatcher.end('skipped');
|
||||
};
|
||||
function vote(serverQueue, message) {
|
||||
serverQueue.votesNeeded = Math.floor(message.guild.voiceConnection.channel.members.size / 2);
|
||||
serverQueue.votesNeeded.toFixed();
|
||||
if (message.guild.voiceConnection.channel.members.size > 2) {
|
||||
if (serverQueue.voters.includes(message.member.id)) return message.channel.send(':x: You have already voted to skip!');
|
||||
serverQueue.votes++;
|
||||
serverQueue.voters.push(message.member.id);
|
||||
if (serverQueue.votes >= serverQueue.votesNeeded) {
|
||||
serverQueue.voters = [];
|
||||
serverQueue.votes = 0;
|
||||
serverQueue.votesNeeded = null;
|
||||
return skipSong(serverQueue, message);
|
||||
} else return message.channel.send(`:x: Not enough votes! ${serverQueue.votes} / ${serverQueue.votesNeeded}!`);
|
||||
} else {
|
||||
return skipSong(serverQueue, message);
|
||||
}
|
||||
};
|
||||
|
@ -2,6 +2,6 @@ module.exports = {
|
||||
token: process.env.TOKEN,
|
||||
api_key: process.env.API_KEY,
|
||||
debug_channel: "634718645188034560",
|
||||
dev: "360363051792203779",
|
||||
devId: "360363051792203779",
|
||||
prefix: ">"
|
||||
}
|
@ -22,7 +22,10 @@ module.exports = async function (video, message, voiceChannel, client, playlist
|
||||
songs: [],
|
||||
volume: client.global.db.guilds[message.guild.id].defaultVolume,
|
||||
playing: true,
|
||||
looping: false
|
||||
looping: false,
|
||||
votes: 0,
|
||||
voters: [],
|
||||
votesNeeded: null
|
||||
};
|
||||
construct.songs.push(song);
|
||||
client.queue.set(message.guild.id, construct);
|
||||
|
1094
package-lock.json
generated
1094
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user