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.
This commit is contained in:
Michael H 2018-09-24 04:21:21 -04:00 committed by Toby Harradine
parent 415385b747
commit 404800c556

View File

@ -436,7 +436,8 @@ class Mod:
using this command""" using this command"""
author = ctx.author author = ctx.author
guild = ctx.guild 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 is_banned = False
ban_list = await guild.bans() ban_list = await guild.bans()
for entry in ban_list: for entry in ban_list:
@ -449,7 +450,9 @@ class Mod:
return return
user = guild.get_member(user_id) user = guild.get_member(user_id)
if user is None: 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 user = discord.Object(id=user_id) # User not in the guild, but
audit_reason = get_audit_reason(author, reason) audit_reason = get_audit_reason(author, reason)