From 5e0dc71b7f1923422828ededdac7dcaeb423bfdc Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Fri, 7 Apr 2017 22:55:13 +0000 Subject: [PATCH] Proper Permission Checks --- commands/avataredit/3000years.js | 3 ++- commands/avataredit/beautiful.js | 3 ++- commands/avataredit/bobross.js | 3 ++- commands/avataredit/rip.js | 3 ++- commands/avataredit/steamcard.js | 3 ++- commands/botinfo/info.js | 3 ++- commands/games/mathgame.js | 3 ++- commands/games/quiz.js | 3 ++- commands/games/typinggame.js | 3 ++- commands/imageedit/meme.js | 3 ++- commands/moderation/ban.js | 4 +++- commands/moderation/kick.js | 4 +++- commands/moderation/prune.js | 4 +++- commands/moderation/unban.js | 4 +++- commands/moderation/warn.js | 3 ++- commands/random/nitro.js | 3 ++- commands/random/spam.js | 3 ++- commands/random/today.js | 3 ++- commands/response/cat.js | 3 ++- commands/response/potato.js | 3 ++- commands/response/pun.js | 3 ++- commands/response/xiaopai.js | 3 ++- commands/search/botinfo.js | 3 ++- commands/search/define.js | 3 ++- commands/search/discrim.js | 3 ++- commands/search/forecast.js | 3 ++- commands/search/imdb.js | 3 ++- commands/search/osu.js | 3 ++- commands/search/pokedex.js | 3 ++- commands/search/urban.js | 3 ++- commands/search/wattpad.js | 3 ++- commands/search/weather.js | 3 ++- commands/search/wikipedia.js | 3 ++- commands/search/youtube.js | 3 ++- commands/search/yugioh.js | 3 ++- commands/textedit/embed.js | 4 +++- commands/textedit/say.js | 3 ++- commands/textedit/webhook.js | 3 ++- commands/userinfo/userinfo.js | 3 ++- commands/util/sendDM.js | 10 ++++++++-- 40 files changed, 91 insertions(+), 41 deletions(-) diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index 965df17f..d5e63749 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -22,7 +22,8 @@ module.exports = class YearsCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index 2c7ebfc0..a32089d7 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -22,7 +22,8 @@ module.exports = class BeautifulCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index 6c6adf50..12fd30f7 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -23,7 +23,8 @@ module.exports = class BobRossCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 65486284..75c38fab 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -23,7 +23,8 @@ module.exports = class RIPCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 2872b394..f92ebb12 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -22,7 +22,8 @@ module.exports = class SteamCardCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/botinfo/info.js b/commands/botinfo/info.js index c45447dc..4330bbc2 100644 --- a/commands/botinfo/info.js +++ b/commands/botinfo/info.js @@ -21,7 +21,8 @@ module.exports = class InfoCommand extends commando.Command { async run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const guilds = await this.client.shard.fetchClientValues('guilds.size'); diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index bd04aa5b..8a27ddb7 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -26,7 +26,8 @@ module.exports = class MathGameCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const level = args.difficulty.toLowerCase(); diff --git a/commands/games/quiz.js b/commands/games/quiz.js index a6fec1c8..d0737816 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -18,7 +18,8 @@ module.exports = class QuizCommand extends commando.Command { async run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log('[Command] ' + message.content); try { diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index 293024bb..e83a0f6d 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -25,7 +25,8 @@ module.exports = class TypingGameCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const level = args.difficulty.toLowerCase(); diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 712b47e4..44f74888 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -39,7 +39,8 @@ module.exports = class MemeCommand extends commando.Command { run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); const type = args.type.toLowerCase(); diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index baf1097c..3fa05692 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -36,7 +36,9 @@ module.exports = class BanCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS', 'BAN_MEMBERS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) return message.say(':x: Error! I don\'t have the Ban Members Permission!'); } console.log(`[Command] ${message.content}`); if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index f051896d..cdfd5e01 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -33,7 +33,9 @@ module.exports = class KickCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS', 'KICK_MEMBERS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return message.say(':x: Error! I don\'t have the Kick Members Permission!'); } console.log(`[Command] ${message.content}`); if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index f92e0dd4..d3d427d6 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -40,7 +40,9 @@ module.exports = class PruneCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['READ_MESSAGES', 'MANAGE_MESSAGES', 'READ_MESSAGE_HISTORY'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGE_HISTORY')) return message.say(':x: Error! I don\'t have the Read Message History Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } console.log(`[Command] ${message.content}`); const count = args.count + 1; diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index afacab5a..093b7f16 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -42,7 +42,9 @@ module.exports = class UnbanCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS', 'BAN_MEMBERS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) return message.say(':x: Error! I don\'t have the Ban Members Permission!'); } console.log(`[Command] ${message.content}`); if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!'); diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index f95710b0..e6fcf4a7 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -33,7 +33,8 @@ module.exports = class WarnCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const userToWarn = args.member; diff --git a/commands/random/nitro.js b/commands/random/nitro.js index 793dd935..8088ab72 100644 --- a/commands/random/nitro.js +++ b/commands/random/nitro.js @@ -14,7 +14,8 @@ module.exports = class NitroCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const embed = new Discord.RichEmbed() diff --git a/commands/random/spam.js b/commands/random/spam.js index 70bda96a..9b991d40 100644 --- a/commands/random/spam.js +++ b/commands/random/spam.js @@ -13,7 +13,8 @@ module.exports = class SpamCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); return message.channel.sendFile('./images/Spam.jpg'); diff --git a/commands/random/today.js b/commands/random/today.js index 0c83d7aa..740985e9 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -18,7 +18,8 @@ module.exports = class TodayCommand extends commando.Command { async run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log('[Command] ' + message.content); try { diff --git a/commands/response/cat.js b/commands/response/cat.js index 7923c1c4..ebdaad99 100644 --- a/commands/response/cat.js +++ b/commands/response/cat.js @@ -13,7 +13,8 @@ module.exports = class CatCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); let cat = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpeg', '12.jpg', '13.jpeg', '14.png', '15.jpg', '16.jpg', '17.jpg', '18.jpg', '19.jpg', '20.jpg']; diff --git a/commands/response/potato.js b/commands/response/potato.js index 089adcc9..5c36bbbe 100644 --- a/commands/response/potato.js +++ b/commands/response/potato.js @@ -16,7 +16,8 @@ module.exports = class PotatoCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); let potato = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.gif', '6.png', '7.jpg', '8.jpg', '9.jpg']; diff --git a/commands/response/pun.js b/commands/response/pun.js index 998ff44c..6b224b84 100644 --- a/commands/response/pun.js +++ b/commands/response/pun.js @@ -13,7 +13,8 @@ module.exports = class RandomPunCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); let pun = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.png', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg', '16.jpg', '17.jpg', '18.jpg', '19.jpg', '20.jpg', '21.jpg', '22.jpg', '23.jpg', '24.jpg', '25.jpg', '26.jpg', '27.jpg', '28.jpg', '29.jpg', '30.jpeg', '31.jpg', '32.jpg', '33.jpg', '34.png', '35.jpg', '36.jpg', '37.jpg', '38.jpg', '39.jpg', '40.jpg', '41.jpg', '42.jpg', '43.jpg', '44.jpg', '45.gif', '46.jpg', '47.jpg', '48.jpg', '49.jpg', '50.jpg', '51.jpg', '52.jpg', '53.jpg']; diff --git a/commands/response/xiaopai.js b/commands/response/xiaopai.js index b65fce8a..14a06e4e 100644 --- a/commands/response/xiaopai.js +++ b/commands/response/xiaopai.js @@ -16,7 +16,8 @@ module.exports = class XiaoCommand extends commando.Command { run(message) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!'); } console.log(`[Command] ${message.content}`); let XiaoPai = ['1.png', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.png', '9.png', '10.png', '11.png', '12.png', '13.jpg', '14.jpg', '15.png', '16.jpg', '17.png', '18.gif', '19.png', '20.jpg', '21.jpg']; diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index f03b7947..2dd3d9d9 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -24,7 +24,8 @@ module.exports = class BotSearchCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const botToFind = args.bot.id; diff --git a/commands/search/define.js b/commands/search/define.js index ea616725..df9cfba6 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -26,7 +26,8 @@ module.exports = class DefineCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const defineThis = encodeURI(args.word); diff --git a/commands/search/discrim.js b/commands/search/discrim.js index 694a15e6..7bf7cc91 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -29,7 +29,8 @@ module.exports = class DiscrimCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const userToSearch = args.discrim; diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 2f1f90b8..15237c85 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -23,7 +23,8 @@ module.exports = class ForecastCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const locationToSearch = args.locationQ; diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 4d841479..7fc023b2 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -25,7 +25,8 @@ module.exports = class IMDBCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const queryMovie = args.movie; diff --git a/commands/search/osu.js b/commands/search/osu.js index 3f7e7d8f..06e2f02c 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -25,7 +25,8 @@ module.exports = class OsuCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const usernameToSearch = args.username; diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index f2b990b4..c4f1b6d0 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -29,7 +29,8 @@ module.exports = class PokedexCommand extends commando.Command { run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const pokemon = args.pokemon.toLowerCase(); diff --git a/commands/search/urban.js b/commands/search/urban.js index 9604742a..f37f8707 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -25,7 +25,8 @@ module.exports = class UrbanCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const wordToDefine = args.word; diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index fb1bd697..4c31ba5e 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -20,7 +20,8 @@ module.exports = class WattpadCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const queryBook = args.book; diff --git a/commands/search/weather.js b/commands/search/weather.js index 501bd732..bc3a4551 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -20,7 +20,8 @@ module.exports = class WeatherCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const locationToSearch = args.locationQ; diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index e2033e31..229697bd 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -20,7 +20,8 @@ module.exports = class WikipediaCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const thingToSearch = args.query.split(')').join('%29'); diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 442efb9a..c13e8db4 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -23,7 +23,8 @@ module.exports = class YouTubeCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const videoToSearch = args.video; diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index 64e0d386..7b531e7c 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -20,7 +20,8 @@ module.exports = class YuGiOhCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const cardName = encodeURI(args.card); diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index 08194af4..714b333e 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -20,7 +20,9 @@ module.exports = class EmbedCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); + if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } console.log(`[Command] ${message.content}`); const embedMessage = args.text; diff --git a/commands/textedit/say.js b/commands/textedit/say.js index ad28492e..9d14873a 100644 --- a/commands/textedit/say.js +++ b/commands/textedit/say.js @@ -25,7 +25,8 @@ module.exports = class SayCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'MANAGE_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } console.log(`[Command] ${message.content}`); const copycat = args.text; diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 6c63c16b..eadee1f0 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -27,7 +27,8 @@ module.exports = class WebhookCommand extends commando.Command { async run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'MANAGE_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!'); } console.log(`[Command] ${message.content}`); const content = args.text; diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index d15adc3f..d9d07e9b 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -27,7 +27,8 @@ module.exports = class UserInfoCommand extends commando.Command { run(message, args) { if (message.channel.type !== 'dm') { - if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; + if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!'); } console.log(`[Command] ${message.content}`); const user = args.user; diff --git a/commands/util/sendDM.js b/commands/util/sendDM.js index 80280270..279bdc58 100644 --- a/commands/util/sendDM.js +++ b/commands/util/sendDM.js @@ -33,13 +33,19 @@ module.exports = class SendDMCommand extends commando.Command { return this.client.isOwner(msg.author); } - run(message, args) { + async run(message, args) { if (message.channel.type !== 'dm') { if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return; } console.log(`[Command] ${message.content}`); const userID = args.userid; const content = args.content; - return this.client.users.get(userID).send(content).catch(err => message.say(':x: Error! Something went wrong!')); + try { + await this.client.users.get(userID).send(content); + return message.say('Success!'); + } + catch (err) { + return message.say(':x: Error! Something went wrong!'); + } } };