Tempban logging improvement (#2993)

* user and guild are logged now

* Added changelog entry

* Make sure Forbidden always triggers this as well
This commit is contained in:
DevilXD 2019-09-14 00:40:54 +02:00 committed by Michael H
parent 682b86c193
commit 77f1da30ea
2 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1 @@
More descriptive tempban unban failure logging

View File

@ -127,16 +127,20 @@ class KickBanMixin(MixinMeta):
unban_time = datetime.utcfromtimestamp(
await self.settings.member(member(uid, guild)).banned_until()
)
now = datetime.utcnow()
if now > unban_time: # Time to unban the user
if datetime.utcnow() > unban_time: # Time to unban the user
user = await self.bot.fetch_user(uid)
queue_entry = (guild.id, user.id)
try:
await guild.unban(user, reason=_("Tempban finished"))
guild_tempbans.remove(uid)
except discord.Forbidden:
log.info("Failed to unban member due to permissions")
except discord.HTTPException as e:
# 50013: Missing permissions error code or 403: Forbidden status
if e.code == 50013 or e.status == 403:
log.info(
f"Failed to unban {user}({user.id}) user from "
f"{guild.name}({guild.id}) guild due to permissions"
)
break # skip the rest of this guild
log.info(f"Failed to unban member: error code: {e.code}")
await asyncio.sleep(60)