From 91c4c30aeecd38d1007bafe506cb6b77e61dbae9 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 21 Aug 2017 21:29:48 +0000 Subject: [PATCH] Attempt to Fix Bug --- commands/moderation/ban.js | 2 +- commands/moderation/hackban.js | 2 +- commands/moderation/kick.js | 2 +- commands/moderation/softban.js | 2 +- commands/moderation/warn.js | 2 +- commands/text-edit/portal-send.js | 2 +- structures/Util.js | 4 +--- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 53168510..2d1ab7df 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -65,7 +65,7 @@ module.exports = class BanCommand extends Command { reason: `${msg.author.tag}: ${reason}` }); await msg.say(`Successfully banned ${member.user.tag}.`); - if (!modlogs) { + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { return msg.say('Could not log the ban to the mod logs.'); } else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { const embed = new MessageEmbed() diff --git a/commands/moderation/hackban.js b/commands/moderation/hackban.js index 408511f2..b2e78e90 100644 --- a/commands/moderation/hackban.js +++ b/commands/moderation/hackban.js @@ -59,7 +59,7 @@ module.exports = class HackbanCommand extends Command { return msg.say(`Could not ban the user: \`${err.message}\``); } await msg.say(`Successfully banned ${user.tag}.`); - if (!modlogs) { + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { return msg.say('Could not log the ban to the mod logs.'); } else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { const embed = new MessageEmbed() diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 496f0c1c..f3ec360f 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -62,7 +62,7 @@ module.exports = class KickCommand extends Command { } await member.kick(`${msg.author.tag}: ${reason}`); await msg.say(`Successfully kicked ${member.user.tag}.`); - if (!modlogs) { + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { return msg.say('Could not log the kick to the mod logs.'); } else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { const embed = new MessageEmbed() diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index acce200c..47f73920 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -66,7 +66,7 @@ module.exports = class SoftbanCommand extends Command { }); await msg.guild.unban(member.user, 'Softban'); await msg.say(`Successfully softbanned ${member.user.tag}.`); - if (!modlogs) { + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { return msg.say('Could not log the softban to the mod logs.'); } else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { const embed = new MessageEmbed() diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index e38759c5..5a5f4894 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -60,7 +60,7 @@ module.exports = class WarnCommand extends Command { await msg.say('Failed to Send DM.'); } await msg.say(`Successfully warned ${member.user.tag}.`); - if (!modlogs) { + if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) { return msg.say('Could not log the warn to the mod logs.'); } else if (modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) { const embed = new MessageEmbed() diff --git a/commands/text-edit/portal-send.js b/commands/text-edit/portal-send.js index 6467af21..04c7313d 100644 --- a/commands/text-edit/portal-send.js +++ b/commands/text-edit/portal-send.js @@ -26,7 +26,7 @@ module.exports = class PortalSendCommand extends Command { async run(msg, args) { const { message } = args; - const channels = this.client.channels.filter(c => c.type === 'text' && c.guild.id !== msg.guild.id); + const channels = this.client.channels.filter(c => c.guild.id !== msg.guild.id); const channel = filterTopics(channels, 'portal').random(); if (!channel) return msg.say('Aww... No channel has an open portal...'); try { diff --git a/structures/Util.js b/structures/Util.js index 46d67bf7..943788b7 100644 --- a/structures/Util.js +++ b/structures/Util.js @@ -44,9 +44,7 @@ class Util { static filterTopics(channels, setting) { return channels.filter(c => { - if (c.type !== 'text') return false; - if (!c.topic) return false; - if (!c.permissionsFor(c.client.user).has('SEND_MESSAGES')) return false; + if (c.type !== 'text' || !c.topic) return false; if (c.topic.includes(`<${setting}>`)) return true; return false; });