diff --git a/commands/bug.js b/commands/bug.js index c6855486..12011d57 100644 --- a/commands/bug.js +++ b/commands/bug.js @@ -3,6 +3,7 @@ module.exports = { description: 'Report a bug', alias: 'bug', cooldown: 5, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const embed = new Discord.RichEmbed() .setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`) diff --git a/commands/eval.js b/commands/eval.js index 6f2cbe40..2ea7270d 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -3,13 +3,13 @@ module.exports = { description: 'Evaluation command', alias: 'eval', cooldown: 5, + onlyDev: true, async execute(message, args, client, Discord, prefix) { const ytdl = require('ytdl-core'); const serverQueue = client.queue.get(message.guild.id); if (serverQueue) { let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); } - if (message.author.id !== client.config.devId) return message.channel.send(':x: You are not allowed to do that!'); const input = message.content.slice(prefix.length + 4); let output; try { diff --git a/commands/forcestop.js b/commands/forcestop.js index 3e0ddb71..8004686a 100644 --- a/commands/forcestop.js +++ b/commands/forcestop.js @@ -3,8 +3,8 @@ module.exports = { description: 'force stop command.', alias: 'fs', cooldown: 5, + onlyDev: true, execute(message, args, client, Discord, prefix) { - if (message.author.id !== client.config.devId) return message.channel.send(':x: You are not allowed to do that!') client.queue.delete(message.guild.id); message.channel.send('queue deleted') } diff --git a/commands/help.js b/commands/help.js index 7c4c68fe..583e693e 100644 --- a/commands/help.js +++ b/commands/help.js @@ -3,6 +3,7 @@ module.exports = { description: 'Help command.', alias: 'help', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const embed = new Discord.RichEmbed() .setTitle('Commands for Musix!') diff --git a/commands/invite.js b/commands/invite.js index 1f464a25..3458a2be 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -3,6 +3,7 @@ module.exports = { description: 'Invite command.', alias: 'invite', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const embed = new Discord.RichEmbed() .setTitle('Invite Musix to your Discord server!') diff --git a/commands/loop.js b/commands/loop.js index 141ef75d..644d2be0 100644 --- a/commands/loop.js +++ b/commands/loop.js @@ -3,12 +3,13 @@ module.exports = { description: 'loop command.', alias: 'loop', cooldown: 10, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; if (serverQueue) { - if (message.author.id !== client.config.devId) { + 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 loop the queue!'); if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].dj) { diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 7002ba00..cbcf572f 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -3,6 +3,7 @@ module.exports = { description: 'Now playing command.', alias: 'np', cooldown: 5, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const ytdl = require('ytdl-core'); const serverQueue = client.queue.get(message.guild.id); diff --git a/commands/pause.js b/commands/pause.js index 9c0a770d..406b8d5b 100644 --- a/commands/pause.js +++ b/commands/pause.js @@ -3,13 +3,14 @@ module.exports = { description: 'Pause command.', alias: 'pause', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; if (serverQueue && serverQueue.playing === true) { 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 pause the music!'); - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { 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 pause the music!'); diff --git a/commands/play.js b/commands/play.js index b1836cd4..382989d7 100644 --- a/commands/play.js +++ b/commands/play.js @@ -8,6 +8,7 @@ module.exports = { alias: 'p', args: true, cooldown: 3, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const youtube = new YouTube(client.config.apikey); const searchString = args.slice(1).join(" "); diff --git a/commands/playlist.js b/commands/playlist.js index afb199b2..6e742bc9 100644 --- a/commands/playlist.js +++ b/commands/playlist.js @@ -7,6 +7,7 @@ module.exports = { description: 'Save and load queues', alias: 'pl', cooldown: 10, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const embed = new Discord.RichEmbed() .setTitle('Options for playlist!') @@ -19,7 +20,7 @@ module.exports = { .setAuthor(client.user.username, client.user.displayAvatarURL) .setColor('#b50002') const permissions = message.channel.permissionsFor(message.author); - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { 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!'); diff --git a/commands/queue.js b/commands/queue.js index 44fcb865..c4d70cc9 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -3,6 +3,7 @@ module.exports = { description: 'Queue command.', alias: 'q', cooldown: 5, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const serverQueue = client.queue.get(message.guild.id); if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); diff --git a/commands/remove.js b/commands/remove.js index 783a3a0f..f42fa6a5 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -3,6 +3,7 @@ module.exports = { description: 'Remove command.', alias: 'rm', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); @@ -13,7 +14,7 @@ module.exports = { if (isNaN(pos)) return message.channel.send(':x: You need to enter a number!'); if (pos === 0) return message.channel.send(':x: You can not remove the currently playing song!'); if (pos > serverQueue.songs.size) return message.channel.send(`:x: There is only ${serverQueue.songs.size} amount of songs in the queue!`); - if (message.author.id !== client.config.devId) { + 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 remove songs!'); if (client.global.db.guilds[message.guild.id].dj) { if (serverQueue.songs[pos].author !== message.author) { diff --git a/commands/resume.js b/commands/resume.js index fddc4e55..a383cdc1 100644 --- a/commands/resume.js +++ b/commands/resume.js @@ -3,12 +3,13 @@ module.exports = { description: 'Resume command.', alias: 'resume', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); const { voiceChannel } = message.member; if (serverQueue && !serverQueue.playing) { - if (message.author.id !== client.config.devId) { + 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 loop the queue!'); if (client.global.db.guilds[message.guild.id].permissions === true) { if (client.global.db.guilds[message.guild.id].dj) { diff --git a/commands/seek.js b/commands/seek.js index 57b8f361..d2241024 100644 --- a/commands/seek.js +++ b/commands/seek.js @@ -3,6 +3,7 @@ module.exports = { description: 'seek command.', alias: 'seek', cooldown: 10, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const ytdl = require('ytdl-core'); const serverQueue = client.queue.get(message.guild.id); @@ -10,7 +11,7 @@ module.exports = { const { voiceChannel } = message.member; let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url)); if (serverQueue) { - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { 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 voice channel as Musix to seek the song!'); if (client.global.db.guilds[message.guild.id].permissions === true) { diff --git a/commands/settings.js b/commands/settings.js index efad45c4..07aa6ae6 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -4,6 +4,7 @@ module.exports = { description: 'Change the settings', alias: 'settings', cooldown: 10, + onlyDev: false, async execute(message, args, client, Discord, prefix) { const embed = new Discord.RichEmbed() .setTitle('Guild settings for Musix') @@ -16,7 +17,7 @@ module.exports = { .setAuthor(client.user.username, client.user.displayAvatarURL) .setColor('#b50002') const permissions = message.channel.permissionsFor(message.author); - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { if (!permissions.has('MANAGE_GUILD')) return message.channel.send(':x: You need the `MANAGE_SERVER` permission to change the settings!'); } if (args[1]) { diff --git a/commands/settings/reset.js b/commands/settings/reset.js new file mode 100644 index 00000000..02baa53d --- /dev/null +++ b/commands/settings/reset.js @@ -0,0 +1,14 @@ +module.exports = { + name: 'reset', + async execute(message, args, client, Discord, prefix) { + client.global.db.guilds[message.guild.id] = { + prefix: client.config.prefix, + defaultVolume: 5, + permissions: false, + premium: false, + dj: false, + djrole: null + }; + message.channel.send(':white_check_mark: Reset __all__ guild settings!'); + } +}; \ No newline at end of file diff --git a/commands/skip.js b/commands/skip.js index 3a782988..2f4ec5ae 100644 --- a/commands/skip.js +++ b/commands/skip.js @@ -3,12 +3,13 @@ module.exports = { description: 'Skip command.', alias: 'skip', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could skip for you.'); - if (message.author.id !== client.config.devId) { + 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) { diff --git a/commands/status.js b/commands/status.js index be07197b..91b0506f 100644 --- a/commands/status.js +++ b/commands/status.js @@ -3,6 +3,7 @@ module.exports = { description: 'Status command.', alias: 'status', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { let rawUptime = client.uptime; let uptime = {}; diff --git a/commands/stop.js b/commands/stop.js index 49edb389..0c26fa21 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -3,11 +3,12 @@ module.exports = { description: 'Stop command.', alias: 'stop', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { if (!serverQueue) return message.channel.send(':x: There is nothing playing that I could stop for you.'); 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 stop the music!'); if (client.global.db.guilds[message.guild.id].permissions === true) { diff --git a/commands/volume.js b/commands/volume.js index 50890cd2..e514b5a2 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -3,15 +3,15 @@ module.exports = { description: 'Volume command.', alias: 'volume', cooldown: 5, + onlyDev: false, execute(message, args, client, Discord, prefix) { const { voiceChannel } = message.member; const serverQueue = client.queue.get(message.guild.id); const permissions = message.channel.permissionsFor(message.author); - if (message.author.id === '384002606621655040') return message.channel.send('You are not doying that!'); if (!serverQueue) return message.channel.send(':x: There is nothing playing.'); if (!args[1]) return message.channel.send(`:loud_sound: The current volume is: **${serverQueue.volume}**`); const volume = parseFloat(args[1]); - if (message.author.id !== client.config.devId) { + if (message.author.id !== client.config.dev) { 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].dj) { diff --git a/config/config.js b/config/config.js new file mode 100644 index 00000000..3e373a33 --- /dev/null +++ b/config/config.js @@ -0,0 +1,7 @@ +module.exports = { + token: process.env.TOKEN, + api_key: process.env.API_KEY, + debug_channel: "634718645188034560", + dev: "360363051792203779", + prefix: ">" +} \ No newline at end of file diff --git a/events/message.js b/events/message.js index febdbc20..b61751f9 100644 --- a/events/message.js +++ b/events/message.js @@ -2,47 +2,24 @@ module.exports = { name: 'message', async execute(client, message, Discord) { if (message.author.bot || !message.guild) return; - if (message.content === '->reset' && message.author.id === client.config.devId) { - client.guilds.forEach(guild => { - client.global.db.guilds[guild.id] = { - prefix: client.config.prefix, - defaultVolume: 5, - permissions: false, - premium: false, - dj: false, - djrole: null - }; - return message.channel.send(':white_check_mark: Reset all guild settings for __all__ guilds!'); - }); - return message.channel.send(':white_check_mark: Reset all guild settings!') - } else if (message.content === '->resetguildsettings' && message.author.id === client.config.devId) { - client.global.db.guilds[message.guild.id] = { - prefix: client.config.prefix, - defaultVolume: 5, - permissions: false, - premium: false, - dj: false, - djrole: null - }; - return message.channel.send(':white_check_mark: Reset all guild settings for this guild!'); - } let prefix = client.global.db.guilds[message.guild.id].prefix; const args = message.content.slice(prefix.length).split(' '); - let commandName; if (message.mentions.users.first()) { if (message.mentions.users.first().id === client.user.id) { if (!args[1]) return; if (args[1] === 'prefix') return message.channel.send(`My prefix here is: \`${prefix}\`.`); - commandName = args[1].toLowerCase(); - const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName); - client.funcs.exe(message, args, client, Discord, prefix, command); + if (args[1] === 'help') { + const command = client.commands.get("help"); + return client.funcs.exe(message, args, client, Discord, prefix, command); + } } } if (!message.content.startsWith(prefix)) return; if (!args[0]) return; - commandName = args[0].toLowerCase(); + const commandName = args[0].toLowerCase(); const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName); if (!command && message.content !== `${prefix}`) return; + if (command.onlyDev && message.author.id !== client.config.dev) return message.channel.send(':x: You are not allowed to do that!'); client.funcs.exe(message, args, client, Discord, prefix, command); } } diff --git a/index.js b/index.js index b94c7cb1..329fd810 100644 --- a/index.js +++ b/index.js @@ -37,13 +37,7 @@ client.funcs.msToTime = require('./funcs/msToTime.js'); client.funcs.dbget = require('./funcs/dbget.js'); client.funcs.exe = require('./funcs/exe.js'); -client.config = { - token: process.env.DISCORD_TOKEN, - debug_channel: process.env.DISCORD_DEBUG_CHANNEL_ID, - apikey: process.env.YOUTUBE_KEY, - devId: process.env.DISCORD_DEV_UID, - prefix: process.env.PREFIX -}; +client.config = require('./config/config.js'); const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js')); for (const file of commandFiles) {