Improve message deletion logic to handle timeout messages and skip invalid webhook token errors
This commit is contained in:
@ -109,12 +109,14 @@ class RemindBotClient(discord.Client):
|
||||
logger.debug("Removing view: %s", msg.id)
|
||||
try:
|
||||
# If the message is "/remind list timed out.", skip it
|
||||
if msg.content == "/remind list timed out.":
|
||||
if "/remind list timed out." in msg.content:
|
||||
logger.debug("Message %s is a timeout message. Skipping.", msg.id)
|
||||
continue
|
||||
|
||||
await msg.delete()
|
||||
except discord.HTTPException as e:
|
||||
if e.status != 401:
|
||||
# Skip if the webhook token is invalid
|
||||
logger.error("Failed to remove view: %s", e) # noqa: TRY400
|
||||
except asyncio.exceptions.CancelledError:
|
||||
logger.error("Failed to remove view: Task was cancelled.") # noqa: TRY400
|
||||
|
Reference in New Issue
Block a user