From 404800c556f99b9bc3e8bfd3fa96842cf3689fbc Mon Sep 17 00:00:00 2001 From: Michael H Date: Mon, 24 Sep 2018 04:21:21 -0400 Subject: [PATCH] Hackban fixes (#2128) If the member is in the guild, delegates to existing ban logic. Additionally, check that we have ban perms prior to attempting to fetch the existing ban list. Fixes #2127. --- redbot/cogs/mod/mod.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/mod/mod.py b/redbot/cogs/mod/mod.py index 09e0ecb36..5ce445126 100644 --- a/redbot/cogs/mod/mod.py +++ b/redbot/cogs/mod/mod.py @@ -436,7 +436,8 @@ class Mod: using this command""" author = ctx.author guild = ctx.guild - + if not guild.me.guild_permissions.ban_members: + return await ctx.send(_("I lack the permissions to do this.")) is_banned = False ban_list = await guild.bans() for entry in ban_list: @@ -449,8 +450,10 @@ class Mod: return user = guild.get_member(user_id) - if user is None: - user = discord.Object(id=user_id) # User not in the guild, but + if user is not None: + # Instead of replicating all that handling... gets attr from decorator + return await ctx.invoke(self.ban, user, None, reason=reason) + user = discord.Object(id=user_id) # User not in the guild, but audit_reason = get_audit_reason(author, reason) queue_entry = (guild.id, user_id)