Added an optional checkPermission function and upgraded quick.db.

This commit is contained in:
Justin 2019-10-30 22:28:49 -04:00
parent 5d778acf20
commit 2c3bf24f59
21 changed files with 215 additions and 66 deletions

0
' Normal file
View file

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -50,9 +50,15 @@ function parseCommand(bot, msg) {
}
if (cmd) {
if (cmd.conf.guildOnly == true) {
if (!msg.channel.guild) {
return msg.reply('This command can only be ran in a guild.');
if (cmd.conf.guildOnly == true && !msg.channel.guild) {
return msg.reply('This command can only be ran in a guild.');
}
if (cmd.checkPermission != null) {
let result = cmd.checkPermission(bot, msg.member)
if (result != true)
{
if (result == false) return msg.reply('You are not authorized to run this command.');
return msg.reply(result);
}
}
try {

135
package-lock.json generated
View file

@ -64,20 +64,12 @@
}
},
"better-sqlite3": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-4.2.0.tgz",
"integrity": "sha512-m6vGein6wZWexQ+yaBSHM8MSoSJ9hU2pO+4Ap5THwS0WSro/RKDvwO9a5m1WYvMTh74snnPTVMWeUmiB12UitQ==",
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-5.4.3.tgz",
"integrity": "sha512-fPp+8f363qQIhuhLyjI4bu657J/FfMtgiiHKfaTsj3RWDkHlWC1yT7c6kHZDnBxzQVoAINuzg553qKmZ4F1rEw==",
"requires": {
"bindings": "^1.3.0",
"integer": "^1.0.5"
}
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"requires": {
"file-uri-to-path": "1.0.0"
"integer": "^2.1.0",
"tar": "^4.4.10"
}
},
"bluebird": {
@ -95,6 +87,11 @@
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chownr": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz",
"integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw=="
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@ -194,11 +191,6 @@
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -214,6 +206,14 @@
"mime-types": "^2.1.12"
}
},
"fs-minipass": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz",
"integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==",
"requires": {
"minipass": "^2.6.0"
}
},
"getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
@ -247,12 +247,9 @@
}
},
"integer": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/integer/-/integer-1.0.7.tgz",
"integrity": "sha512-V/HQn/gkGjY5La5r1bzOkCSwnmrk+DmiZ8jWJMiW2zwLhU9plNvOSh1jcYUHa5ee/7u6DXKjws5b2I7QPW1+Nw==",
"requires": {
"bindings": "^1.3.0"
}
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/integer/-/integer-2.1.0.tgz",
"integrity": "sha512-vBtiSgrEiNocWvvZX1RVfeOKa2mCHLZQ2p9nkQkQZ/BvEiY+6CcUz0eyjvIiewjJoeNidzg2I+tpPJvpyspL1w=="
},
"is-buffer": {
"version": "1.1.6",
@ -305,6 +302,21 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.set": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz",
"integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM="
},
"lodash.unset": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.unset/-/lodash.unset-4.5.2.tgz",
"integrity": "sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0="
},
"long": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz",
@ -333,6 +345,43 @@
"mime-db": "1.40.0"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"minipass": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
"integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
}
}
},
"minizlib": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz",
"integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==",
"requires": {
"minipass": "^2.9.0"
}
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@ -364,12 +413,14 @@
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"quick.db": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/quick.db/-/quick.db-5.5.1.tgz",
"integrity": "sha1-Irj1lBKnR9+6C07qVsVf+whwL30=",
"version": "7.0.0-b22",
"resolved": "https://registry.npmjs.org/quick.db/-/quick.db-7.0.0-b22.tgz",
"integrity": "sha512-Qi3Mx2ho1M0rWzVwrjh5zqmlNVTLqO6WgaI1suZ4qOxhjD3CFcH2nvOnL7o3kan5C0taCrs9/n4EIvq6CgpCaQ==",
"requires": {
"better-sqlite3": "^4.1.0",
"lodash": "^4.17.5"
"better-sqlite3": "^5.0.1",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
"lodash.unset": "^4.5.2"
}
},
"raven": {
@ -499,6 +550,27 @@
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
},
"tar": {
"version": "4.4.13",
"resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz",
"integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==",
"requires": {
"chownr": "^1.1.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.8.6",
"minizlib": "^1.2.1",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.2",
"yallist": "^3.0.3"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
}
}
},
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
@ -571,6 +643,11 @@
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0"
}
},
"yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
}
}
}

View file

@ -11,7 +11,7 @@
"dependencies": {
"dblapi.js": "^1.2.0",
"discord.js": "^11.3.0",
"quick.db": "^5.3.8",
"quick.db": "^7.0.0-b22",
"raven": "^2.6.0",
"request": "^2.88.0",
"request-promise": "^4.2.4",