1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 01:21:56 +00:00

DJ role support

This commit is contained in:
MatteZ02 2019-10-13 10:33:59 +03:00
parent 1b4dd3921b
commit ca61906f57
13 changed files with 64 additions and 14 deletions

View File

@ -10,7 +10,9 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to loop the queue!'); 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 loop the queue!');
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to loop the queue!');
} }
} }
if (!serverQueue.looping) { if (!serverQueue.looping) {

View File

@ -10,7 +10,9 @@ module.exports = {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to pause the music!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to pause the music!');
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!'); 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 pause the music!');
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to pause the music!');
} }
} }
serverQueue.playing = false; serverQueue.playing = false;

View File

@ -7,7 +7,9 @@ module.exports = {
const permissions = message.channel.permissionsFor(message.author); const permissions = message.channel.permissionsFor(message.author);
const serverQueue = client.queue.get(message.guild.id); const serverQueue = client.queue.get(message.guild.id);
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to modify the playlist!'); 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 modify or play the playlist!');
} else if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to modify the playlist!');
} }
if (client.global.db.guilds[message.guild.id].premium) { if (client.global.db.guilds[message.guild.id].premium) {
if (args[1] === 'play') { if (args[1] === 'play') {
@ -49,7 +51,7 @@ module.exports = {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle('Options for playlist!') .setTitle('Options for playlist!')
.addField('play', 'Play the guild specific queue.', true) .addField('play', 'Play the guild specific queue.', true)
.addField('save', 'Save the currently playing queue.') .addField('save', 'Save the currently playing queue.', true)
.setFooter(`how to use: ${prefix}playlist <Option>`) .setFooter(`how to use: ${prefix}playlist <Option>`)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002') .setColor('#b50002')

View File

@ -10,7 +10,9 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to loop the queue!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!'); 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 resume the music!');
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to resume the music!');
} }
} }
serverQueue.playing = true; serverQueue.playing = true;

View File

@ -13,7 +13,9 @@ module.exports = {
return message.channel.send(':x: This command is currently disabled!'); return message.channel.send(':x: This command is currently disabled!');
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to seek the song!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to seek the song!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to seek the song!'); 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 seek the song!');
} else if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to seek the song!');
} }
} }
if (!args[1]) return message.channel.send(`:x: Correct usage: \`${prefix}seek <seeking point in seconds>\``); if (!args[1]) return message.channel.send(`:x: Correct usage: \`${prefix}seek <seeking point in seconds>\``);

View File

@ -21,17 +21,17 @@ module.exports = {
} else if (args[1] === 'permissions') { } else if (args[1] === 'permissions') {
if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.guilds[message.guild.id].permissions}\``); if (!args[2]) return message.channel.send(`🔒 Permission requirement: \`${client.global.db.guilds[message.guild.id].permissions}\``);
if (args[2] === 'true') { if (args[2] === 'true') {
if (client.global.db.guilds[message.guild.id].permissions === false) { if (!client.global.db.guilds[message.guild.id].permissions) {
client.global.db.guilds[message.guild.id].permissions = true; client.global.db.guilds[message.guild.id].permissions = true;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`true\``); message.channel.send(`:white_check_mark: Permissions requirement now set to: \`true\``);
} else return message.channel.send(':x: That value is already `true`!'); } else return message.channel.send(':x: That value is already `true`!');
} else if (args[2] === 'false') { } else if (args[2] === 'false') {
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions) {
client.global.db.guilds[message.guild.id].permissions = false; client.global.db.guilds[message.guild.id].permissions = false;
message.channel.send(`:white_check_mark: Permissions requirement now set to: \`false\``); message.channel.send(`:white_check_mark: Permissions requirement now set to: \`false\``);
} else return message.channel.send(':x: That value is already `false`!'); } else return message.channel.send(':x: That value is already `false`!');
} else return message.channel.send(':x: Please define a boolean! (true/false)'); } else return message.channel.send(':x: Please define a boolean! (true/false)');
} else if (args[1] === 'setPremium' && message.author.id === '360363051792203779') { } else if (args[1] === 'setpremium' && message.author.id === '360363051792203779') {
if (args[2]) { if (args[2]) {
const guild = client.guilds.get(args[2]); const guild = client.guilds.get(args[2]);
if (!client.global.db.guilds[guild.id].premium) { if (!client.global.db.guilds[guild.id].premium) {
@ -60,12 +60,36 @@ module.exports = {
message.channel.send(":white_check_mark: This guild is no longer premium!") message.channel.send(":white_check_mark: This guild is no longer premium!")
} }
} }
} else if (args[1] === "setdj") {
if (!client.global.db.guilds[message.guild.id].dj) {
if (!client.global.db.guilds[message.guild.id].permissions) {
client.global.db.guilds[message.guild.id].permissions = true;
}
client.global.db.guilds[message.guild.id].dj = true;
if (message.guild.roles.find(x => x.name === "DJ")) {
client.global.db.guilds[message.guild.id].djrole = message.guild.roles.find(x => x.name === "DJ").id;
message.channel.send(':white_check_mark: I found a `DJ` role from this guild! This role is now the DJ role.');
} else {
const permissions = message.channel.permissionsFor(message.client.user);
if (!permissions.has('MANAGE_ROLES')) return message.channel.send(':x: I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!');
message.guild.createRole({
name: 'DJ',
})
.then(role => client.global.db.guilds[message.guild.id].djrole = role.id)
.catch(console.error)
message.channel.send(':white_check_mark: I did not find a role `DJ` so i have created one for you!');
}
} else {
client.global.db.guilds[message.guild.id].dj = false;
message.channel.send(':white_check_mark: `DJ` now set to `false`');
}
} else { } else {
const embed = new Discord.RichEmbed() const embed = new Discord.RichEmbed()
.setTitle('Guild settings for Musix') .setTitle('Guild settings for Musix')
.addField('prefix', 'Change the guild specific prefix.', true) .addField('prefix', 'Change the guild specific prefix.', true)
.addField('volume', 'Change the default volume that the bot will start playing at.', true) .addField('volume', 'Change the default volume that the bot will start playing at.', true)
.addField('permissions', 'Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`') .addField('permissions', 'Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`', true)
.addField('setdj', 'Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!', true)
.setFooter(`how to use: ${prefix}settings <Setting name> <value>`) .setFooter(`how to use: ${prefix}settings <Setting name> <value>`)
.setAuthor(client.user.username, client.user.displayAvatarURL) .setAuthor(client.user.username, client.user.displayAvatarURL)
.setColor('#b50002') .setColor('#b50002')

View File

@ -10,7 +10,9 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to skip the song!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to skip the song!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_MESSAGES')) return message.channel.send(':x: You need the `MANAGE_MESSAGES` permission to skip songs!'); 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!');
} }
} }
message.channel.send(':fast_forward: Skipped the song!'); message.channel.send(':fast_forward: Skipped the song!');

View File

@ -10,7 +10,9 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to stop the music!'); if (voiceChannel !== serverQueue.voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in the same voiceChannel as Musix to stop the music!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!'); 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 stop the music!');
} else if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to stop the music!');
} }
} }
serverQueue.songs = []; serverQueue.songs = [];

View File

@ -12,7 +12,9 @@ module.exports = {
if (message.author.id !== '360363051792203779') { if (message.author.id !== '360363051792203779') {
if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to change the volume!'); if (!voiceChannel) return message.channel.send(':x: I\'m sorry but you need to be in a voice channel to change the volume!');
if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].permissions === true) {
if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to change the volume!'); 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 change the volume!');
} else if (!permissions.has('MANAGE_CHANNELS')) return message.channel.send(':x: You need the `MANAGE_CHANNELS` permission to change the volume!');
} }
if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.'); if (isNaN(args[1])) return message.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
if (args[1] > 100) return message.channel.send(':x: The max volume is `100`!'); if (args[1] > 100) return message.channel.send(':x: The max volume is `100`!');

View File

@ -6,12 +6,16 @@ module.exports = {
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false,
djrole: null
}); });
client.global.db.guilds[guild.id] = { client.global.db.guilds[guild.id] = {
prefix: ">", prefix: ">",
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false,
djrole: null
}; };
} }
} }

View File

@ -9,6 +9,8 @@ module.exports = {
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false,
djrole: null
}; };
}); });
return message.channel.send(':white_check_mark: Reset all guild settings!') return message.channel.send(':white_check_mark: Reset all guild settings!')
@ -18,6 +20,8 @@ module.exports = {
defaultVolume: 5, defaultVolume: 5,
permissions: false, permissions: false,
premium: false, premium: false,
dj: false,
djrole: null
}; };
} }
let prefix = client.global.db.guilds[message.guild.id].prefix; let prefix = client.global.db.guilds[message.guild.id].prefix;

View File

@ -20,6 +20,8 @@ module.exports = {
defaultVolume: client.global.db.guilds[guild.id].defaultVolume, defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
permissions: client.global.db.guilds[guild.id].permissions, permissions: client.global.db.guilds[guild.id].permissions,
premium: client.global.db.guilds[guild.id].premium, premium: client.global.db.guilds[guild.id].premium,
dj: client.global.db.guilds[guild.id].dj,
djrole: client.global.db.guilds[guild.id].djrole,
}); });
if (client.global.db.guilds[guild.id].premium) { if (client.global.db.guilds[guild.id].premium) {
client.db.collection('playlists').doc(guild.id).set({ client.db.collection('playlists').doc(guild.id).set({

View File

@ -35,7 +35,7 @@ client.funcs.dbget = require('./funcs/dbget.js');
client.config = { client.config = {
token: process.env.TOKEN, token: process.env.TOKEN,
apikey: process.env.API_KEY2, apikey: process.env.API_KEY,
prefix: '>', prefix: '>',
test: 'success', test: 'success',
}; };