1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 02:00:20 +00:00
This commit is contained in:
MatteZ02 2019-11-19 15:59:14 +02:00
parent c32d592074
commit 698bb0eb9b
5 changed files with 53 additions and 1088 deletions

View File

@ -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!");

View File

@ -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);
}
};

View File

@ -2,6 +2,6 @@ module.exports = {
token: process.env.TOKEN,
api_key: process.env.API_KEY,
debug_channel: "634718645188034560",
dev: "360363051792203779",
devId: "360363051792203779",
prefix: ">"
}

View File

@ -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

File diff suppressed because it is too large Load Diff