mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
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:
parent
682b86c193
commit
77f1da30ea
1
changelog.d/mod/2993.misc.rst
Normal file
1
changelog.d/mod/2993.misc.rst
Normal file
@ -0,0 +1 @@
|
|||||||
|
More descriptive tempban unban failure logging
|
||||||
@ -127,16 +127,20 @@ class KickBanMixin(MixinMeta):
|
|||||||
unban_time = datetime.utcfromtimestamp(
|
unban_time = datetime.utcfromtimestamp(
|
||||||
await self.settings.member(member(uid, guild)).banned_until()
|
await self.settings.member(member(uid, guild)).banned_until()
|
||||||
)
|
)
|
||||||
now = datetime.utcnow()
|
if datetime.utcnow() > unban_time: # Time to unban the user
|
||||||
if now > unban_time: # Time to unban the user
|
|
||||||
user = await self.bot.fetch_user(uid)
|
user = await self.bot.fetch_user(uid)
|
||||||
queue_entry = (guild.id, user.id)
|
queue_entry = (guild.id, user.id)
|
||||||
try:
|
try:
|
||||||
await guild.unban(user, reason=_("Tempban finished"))
|
await guild.unban(user, reason=_("Tempban finished"))
|
||||||
guild_tempbans.remove(uid)
|
guild_tempbans.remove(uid)
|
||||||
except discord.Forbidden:
|
|
||||||
log.info("Failed to unban member due to permissions")
|
|
||||||
except discord.HTTPException as e:
|
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}")
|
log.info(f"Failed to unban member: error code: {e.code}")
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user