[Mod] fix duplicate cases on ban/unban (fixes Cog-Creators/Red-DiscordBot/issues/1052) (#1064)

This commit is contained in:
palmtree5 2017-11-05 16:02:45 -09:00 committed by GitHub
parent 897adbf5ac
commit d6fce3c145
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1167,8 +1167,9 @@ class Mod:
mod = audit_case.user
reason = audit_case.reason
for case in sorted(modlog_cases, key=lambda x: x.case_number, reverse=True):
if case.moderator == mod and case.user == member\
if mod == guild.me and case.user == member\
and case.action_type in ["ban", "hackban"]:
log.info("Case already exists for ban of {}".format(member.name))
break
else: # no ban, softban, or hackban case with the mod and user combo
try:
@ -1231,8 +1232,9 @@ class Mod:
cases = await modlog.get_all_cases(guild, self.bot)
for case in sorted(cases, key=lambda x: x.case_number, reverse=True):
if case.moderator == mod and case.user == user\
and case.action_type == "unban":
if mod == guild.me and case.user == user\
and case.action_type == "unban":
log.info("Case already exists for unban of {}".format(user.name))
break
else:
try: