Make audit_type optional in casetypes (#1119)

This commit is contained in:
Tobotimus
2017-11-23 17:17:42 +11:00
committed by palmtree5
parent acbb5b1720
commit 2c96844209
2 changed files with 22 additions and 20 deletions

View File

@@ -128,16 +128,17 @@ class ModLog:
bot_perms = guild.me.guild_permissions
if bot_perms.view_audit_log:
case_type = await modlog.get_casetype(case_before.action_type, guild)
audit_type = getattr(discord.AuditLogAction, case_type.audit_type)
if audit_type:
audit_case = None
async for entry in guild.audit_logs(action=audit_type):
if entry.target.id == case_before.user.id and \
entry.user.id == case_before.moderator.id:
audit_case = entry
break
if audit_case:
case_before.moderator = audit_case.user
if case_type is not None and case_type.audit_type is not None:
audit_type = getattr(discord.AuditLogAction, case_type.audit_type)
if audit_type:
audit_case = None
async for entry in guild.audit_logs(action=audit_type):
if entry.target.id == case_before.user.id and \
entry.user.id == case_before.moderator.id:
audit_case = entry
break
if audit_case:
case_before.moderator = audit_case.user
is_guild_owner = author == guild.owner
is_case_author = author == case_before.moderator
author_is_mod = await ctx.bot.is_mod(author)