diff options
| author | Justin <jtsshieh@outlook.com> | 2019-10-30 22:28:49 -0400 |
|---|---|---|
| committer | Justin <jtsshieh@outlook.com> | 2019-10-30 22:28:49 -0400 |
| commit | 2c3bf24f5996753df4a2d4456949fc0b636f6366 (patch) | |
| tree | 27700e9b0557d23a6fb0cbd9d4058d60d725caa0 /commands | |
| parent | 5d778acf2066546de30f53d4d10c92a043a44a3a (diff) | |
| download | PokeBot-2c3bf24f5996753df4a2d4456949fc0b636f6366.tar.gz PokeBot-2c3bf24f5996753df4a2d4456949fc0b636f6366.tar.bz2 PokeBot-2c3bf24f5996753df4a2d4456949fc0b636f6366.zip | |
Added an optional checkPermission function and upgraded quick.db.
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/Getting Started/help.js | 12 | ||||
| -rw-r--r-- | commands/Moderation/ban.js | 6 | ||||
| -rw-r--r-- | commands/Moderation/interrogate.js | 6 | ||||
| -rw-r--r-- | commands/Moderation/jail.js | 6 | ||||
| -rw-r--r-- | commands/Moderation/kick.js | 6 | ||||
| -rw-r--r-- | commands/Moderation/purge.js | 6 | ||||
| -rw-r--r-- | commands/Moderation/setLogs.js | 7 | ||||
| -rw-r--r-- | commands/Moderation/setSuggestions.js | 7 | ||||
| -rw-r--r-- | commands/Moderation/softban.js | 7 | ||||
| -rw-r--r-- | commands/Moderation/timeout.js | 5 | ||||
| -rw-r--r-- | commands/Moderation/warn.js | 6 | ||||
| -rw-r--r-- | commands/Owners Only/eval.js | 6 | ||||
| -rw-r--r-- | commands/Owners Only/leaveguild.js | 6 | ||||
| -rw-r--r-- | commands/Owners Only/modifycredits.js | 7 | ||||
| -rw-r--r-- | commands/Owners Only/poweroff.js | 18 | ||||
| -rw-r--r-- | commands/Owners Only/say.js | 14 | ||||
| -rw-r--r-- | commands/Owners Only/testingcredits.js | 7 |
17 files changed, 99 insertions, 33 deletions
diff --git a/commands/Getting Started/help.js b/commands/Getting Started/help.js index 1fb2101..03dc3de 100644 --- a/commands/Getting Started/help.js +++ b/commands/Getting Started/help.js @@ -24,9 +24,17 @@ exports.run = (bot, msg, args) => { const commands = bot.categories.get(x); commands.forEach(cmd => { const command = bot.commands.get(x).get(cmd); - cat += `**${command.help.name}**\n`; + if (command.checkPermission != null) { + if (command.checkPermission(bot, msg.member) == true) + { + cat += `**${command.help.name}**\n`; + } + } + else { + cat += `**${command.help.name}**\n`; + } }); - embed.addField(x, cat, true); + if (cat != '') embed.addField(x, cat, true); }); msg.channel.send({ embed }); } diff --git a/commands/Moderation/ban.js b/commands/Moderation/ban.js index b9ffa4d..593d9e7 100644 --- a/commands/Moderation/ban.js +++ b/commands/Moderation/ban.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('BAN_MEMBERS')) return msg.reply('You don\'t have permission to ban members.'); if (!msg.guild.member(bot.user).hasPermission('BAN_MEMBERS')) return msg.reply('I don\'t have permission to ban members.'); const member = msg.mentions.members.first(); @@ -42,6 +41,11 @@ exports.run = async (bot, msg, args) => { } }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('BAN_MEMBERS')) return 'You don\'t have permission to ban members.'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/interrogate.js b/commands/Moderation/interrogate.js index 821c93a..39c10a1 100644 --- a/commands/Moderation/interrogate.js +++ b/commands/Moderation/interrogate.js @@ -10,7 +10,6 @@ exports.run = async (bot, msg) => { if (msg.guild.id != '417088992329334792') return msg.reply ('This is a PokeWorld exclusive command. Sorry!'); - if (!msg.member.hasPermission('BAN_MEMBERS')) return msg.reply('You don\'t have permission to interrogate others. Rip-off detectives...'); if (!msg.guild.member(bot.user).hasPermission('MANAGE_ROLES')) return msg.reply('I cannot interrogate anyone.'); const member = msg.mentions.members.first(); @@ -36,6 +35,11 @@ exports.run = async (bot, msg) => { } }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('BAN_MEMBERS')) return 'You don\'t have permission to interrogate others. Rip-off detectives...'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/jail.js b/commands/Moderation/jail.js index 2dc50cf..87d18da 100644 --- a/commands/Moderation/jail.js +++ b/commands/Moderation/jail.js @@ -10,7 +10,6 @@ exports.run = async (bot, msg) => { if (msg.guild.id != '417088992329334792') return msg.reply ('This is a PokeWorld exclusive command. Sorry!'); - if (!msg.member.hasPermission('BAN_MEMBERS')) return msg.reply('You don\'t have permission to put members in jail.'); if (!msg.guild.member(bot.user).hasPermission('MANAGE_ROLES')) return msg.reply('I cannot put anyone in jail.'); const member = msg.mentions.members.first(); @@ -36,6 +35,11 @@ exports.run = async (bot, msg) => { } }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('BAN_MEMBERS')) return 'You don\'t have permission to put members in jail.'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/kick.js b/commands/Moderation/kick.js index 174e867..3ee88ea 100644 --- a/commands/Moderation/kick.js +++ b/commands/Moderation/kick.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('KICK_MEMBERS')) return msg.reply('You don\'t have permission to kick members.'); if (!msg.guild.member(bot.user).hasPermission('KICK_MEMBERS')) return msg.reply('I don\'t have permission to kick members.'); const member = msg.mentions.members.first(); @@ -20,6 +19,11 @@ exports.run = async (bot, msg, args) => { msg.channel.send(`Alright, I kicked **${member.user.tag}**${(reason ? ` for the reason **${reason}**.` : '.')}`); }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('KICK_MEMBERS')) return 'You don\'t have permission to kick members.'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/purge.js b/commands/Moderation/purge.js index 6ce557c..f244960 100644 --- a/commands/Moderation/purge.js +++ b/commands/Moderation/purge.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('MANAGE_MESSAGES')) return msg.reply('You don\'t have permission to manage messages.'); if (!msg.guild.member(bot.user).hasPermission('MANAGE_MESSAGES')) return msg.reply('I don\'t have permission to manage messages.'); const user = msg.mentions.users.first(); @@ -27,6 +26,11 @@ exports.run = async (bot, msg, args) => { msg.channel.bulkDelete(msgs).catch(error => console.log(error.stack)); }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('MANAGE_MESSAGES')) return 'You don\'t have permission to manage messages.'; + return true; +} + exports.conf = { aliases: ['prune', 'rm'], guildOnly: true, diff --git a/commands/Moderation/setLogs.js b/commands/Moderation/setLogs.js index 8ae50ea..e951c45 100644 --- a/commands/Moderation/setLogs.js +++ b/commands/Moderation/setLogs.js @@ -8,11 +8,16 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('MANAGE_MESSAGES')) return msg.reply('You don\'t have permission to manage messages.'); bot.plugins.settings.setStr('logs', args[0], msg.guild.id); msg.reply('Alright, I have set the log channel to ' + args[0]); }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('MANAGE_MESSAGES')) return 'You don\'t have permission to manage messages.'; + return true; +} + + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/setSuggestions.js b/commands/Moderation/setSuggestions.js index 2a9d1bd..ff5691e 100644 --- a/commands/Moderation/setSuggestions.js +++ b/commands/Moderation/setSuggestions.js @@ -8,11 +8,16 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('MANAGE_MESSAGES')) return msg.reply('You don\'t have permission to manage messages.'); bot.plugins.settings.setStr('suggestions', args[0], msg.guild.id); msg.reply('Alright, I have set the suggestions channel to ' + args[0]); }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('MANAGE_MESSAGES')) return 'You don\'t have permission to manage messages.'; + return true; +} + + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/softban.js b/commands/Moderation/softban.js index dd5b4a9..7c5119b 100644 --- a/commands/Moderation/softban.js +++ b/commands/Moderation/softban.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('BAN_MEMBERS')) return msg.reply('You don\'t have permission to ban members.'); if (!msg.guild.member(bot.user).hasPermission('BAN_MEMBERS')) return msg.reply('I don\'t have permission to ban members.'); const member = msg.mentions.members.first(); @@ -48,6 +47,12 @@ exports.run = async (bot, msg, args) => { } }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('BAN_MEMBERS')) return 'You don\'t have permission to ban members.'; + return true; +} + + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/timeout.js b/commands/Moderation/timeout.js index 294ebd5..d8722a8 100644 --- a/commands/Moderation/timeout.js +++ b/commands/Moderation/timeout.js @@ -36,6 +36,11 @@ exports.run = async (bot, msg) => { } }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('BAN_MEMBERS')) return 'You don\'t have permission to put members in time-out..'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Moderation/warn.js b/commands/Moderation/warn.js index 1dd0410..b8548a3 100644 --- a/commands/Moderation/warn.js +++ b/commands/Moderation/warn.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!msg.member.hasPermission('MANAGE_MESSAGES')) return msg.reply('You don\'t have permission to warn.'); args.shift(); const warnReason = args.join(' '); const victim = msg.mentions.members.first(); @@ -43,6 +42,11 @@ exports.run = async (bot, msg, args) => { ); }; +exports.checkPermission = (bot, member) => { + if (!member.hasPermission('MANAGE_MESSAGES')) return 'You don\'t have permission to warn.'; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Owners Only/eval.js b/commands/Owners Only/eval.js index 09aac08..5153b63 100644 --- a/commands/Owners Only/eval.js +++ b/commands/Owners Only/eval.js @@ -8,7 +8,6 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(msg.author.id)) return msg.reply('Nope! You need the person who created this bot to use this command.'); const { RichEmbed } = require('discord.js'); const code = args.join(' '); @@ -63,6 +62,11 @@ exports.run = async (bot, msg, args) => { } }; +exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; +} + exports.conf = { aliases: ['exec'], guildOnly: false, diff --git a/commands/Owners Only/leaveguild.js b/commands/Owners Only/leaveguild.js index 2af5244..f214b8b 100644 --- a/commands/Owners Only/leaveguild.js +++ b/commands/Owners Only/leaveguild.js @@ -7,11 +7,15 @@ * * *************************************/ module.exports.run = async (bot, msg) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409', msg.guild.owner.user.id].includes(msg.author.id)) return msg.reply('Nope! You need the person who created this bot or the owner of this guild to use this command.'); msg.channel.send('Alright, I\'m leaving the server now. Bye everyone!') msg.guild.leave(); }; + exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; + } + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Owners Only/modifycredits.js b/commands/Owners Only/modifycredits.js index 050d74d..6ec7506 100644 --- a/commands/Owners Only/modifycredits.js +++ b/commands/Owners Only/modifycredits.js @@ -8,8 +8,6 @@ * *************************************/ exports.run = async (bot, msg) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409', '269516487566426112'].includes(msg.author.id)) return msg.reply('Nope! You need the person who created this bot to use this command.'); - let user; if (!msg.mentions.users.first()) { user = msg.author; @@ -24,6 +22,11 @@ exports.run = async (bot, msg) => { msg.channel.send(`Reset ${user.tag}'s credits.`); }; +exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Owners Only/poweroff.js b/commands/Owners Only/poweroff.js index e369b0a..3d2cbdd 100644 --- a/commands/Owners Only/poweroff.js +++ b/commands/Owners Only/poweroff.js @@ -8,17 +8,17 @@ * *************************************/ exports.run = async (bot, msg) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(msg.author.id)) { - msg.reply('Nope! You need the person who created this bot to use this command.'); - } - else { - await msg.reply(':warning: Pokebot is now powering off!'); - await bot.user.setStatus('invisible') - console.log('Pokebot is now powering off...'); - process.exit(0); - } + await msg.reply(':warning: Pokebot is now powering off!'); + await bot.user.setStatus('invisible') + console.log('Pokebot is now powering off...'); + process.exit(0); }; +exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; +} + exports.conf = { aliases: ['reboot', 'restart'], guildOnly: true, diff --git a/commands/Owners Only/say.js b/commands/Owners Only/say.js index 3085d53..ace2874 100644 --- a/commands/Owners Only/say.js +++ b/commands/Owners Only/say.js @@ -8,15 +8,15 @@ * *************************************/ exports.run = async (bot, msg, args) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409', '269516487566426112'].includes(msg.author.id)) { - msg.reply('Nope! You need the person who created this bot to use this command.'); - } - else { - msg.channel.send(args.join(' ')); - msg.delete(); - } + msg.channel.send(args.join(' ')); + msg.delete(); }; +exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; +} + exports.conf = { aliases: [], guildOnly: true, diff --git a/commands/Owners Only/testingcredits.js b/commands/Owners Only/testingcredits.js index bee93b2..85cc859 100644 --- a/commands/Owners Only/testingcredits.js +++ b/commands/Owners Only/testingcredits.js @@ -8,8 +8,6 @@ * *************************************/ exports.run = async (bot, msg) => { - if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(msg.author.id)) return msg.reply('Nope! You need the person who created this bot to use this command.'); - let user; if (!msg.mentions.members.first()) { user = msg.author; @@ -22,6 +20,11 @@ exports.run = async (bot, msg) => { msg.channel.send('Added 1000 credits'); }; +exports.checkPermission = (bot, member) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(member.id)) return false; + return true; +} + exports.conf = { aliases: [], guildOnly: true, |
