From 99ba4eea17e41c13b3989d7ca6e35863c895739e Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Tue, 5 Jun 2018 18:04:17 +0100 Subject: [Verification] Don't break if another bot removed the message --- bot/cogs/verification.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bot/cogs/verification.py b/bot/cogs/verification.py index 83a31c15a..d9e27d652 100644 --- a/bot/cogs/verification.py +++ b/bot/cogs/verification.py @@ -1,6 +1,6 @@ import logging -from discord import Message, Object +from discord import Message, Object, NotFound from discord.ext.commands import Bot, Context, command from bot.constants import Channels, Roles @@ -42,7 +42,11 @@ class Verification: ) log.trace(f"Deleting the message posted by {ctx.author}") - await ctx.message.delete() + + try: + await ctx.message.delete() + except NotFound: + log.trace("No message found, it must have been deleted by another bot.") @command(name="accept", hidden=True, aliases=["verify", "verified", "accepted", "accept()"]) @without_role(Roles.verified) @@ -56,7 +60,11 @@ class Verification: await ctx.author.add_roles(Object(Roles.verified), reason="Accepted the rules") log.trace(f"Deleting the message posted by {ctx.author}.") - await ctx.message.delete() + + try: + await ctx.message.delete() + except NotFound: + log.trace("No message found, it must have been deleted by another bot.") def setup(bot): -- cgit v1.2.3