Skip to content

Commit

Permalink
Improve error handling a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ToothyDev committed Aug 24, 2024
1 parent d88b909 commit 7ffe4a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cogs/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def auto_kicker(self):
try:
await member.send(
"You've been kicked from The Paw Kingdom for being inactive for too long. You can rejoin and restart the verification process.")
except (Exception, discord.Forbidden):
except (discord.HTTPException, discord.Forbidden):
pass
try:
await member.kick(reason="Inactive Member")
Expand Down
10 changes: 4 additions & 6 deletions utils/member_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ async def userbot_kicker(member: discord.Member):
try:
await member.send(
"You've been kicked from The Paw Kingdom for botlike behaviour. If you are a human, rejoin and select different selfroles")
except (Exception, discord.Forbidden):
except (discord.HTTPException, discord.Forbidden):
pass
try:
await member.kick(reason="Bot")
except Exception as e:
except (discord.HTTPException, discord.Forbidden) as e:
print(f"Unable to kick bot {member.display_name} ({member.id}). Error:\n{e}")
return False # Failsafe
await log_member_kick(member, "Bot")
Expand All @@ -66,13 +66,11 @@ async def spammer_kicker(member: discord.Member) -> bool:
try:
await member.send(
"You've been kicked from The Paw Kingdom for being flagged as spammer.")
except discord.Forbidden:
pass
except discord.HTTPException as e:
except (discord.HTTPException, discord.Forbidden):
pass
try:
await member.kick(reason="Spammer")
except Exception as e:
except (discord.HTTPException, discord.Forbidden) as e:
print(f"Unable to kick spammer {member.display_name} ({member.id}). Error:\n{e}")
return False # Member is a spammer, tho failsafe because it failed
await log_member_kick(member, "Spammer")
Expand Down

0 comments on commit 7ffe4a2

Please sign in to comment.