Skip to content

Commit

Permalink
Supress error messages for trying to delete messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nfaltermeier committed Nov 20, 2022
1 parent 08bbe8c commit 1c59755
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ async def on_message(message: discord.Message):
return

if message.content.startswith('$version'):
time = datetime.fromisoformat(autogen_buildtime.build_time)
await message.channel.send(f'Build time: {time.strftime("%b %d %Y %X %Z")}', delete_after=300)
await asyncio.sleep(300)
await message.delete()
try:
time = datetime.fromisoformat(autogen_buildtime.build_time)
await message.channel.send(f'Build time: {time.strftime("%b %d %Y %X %Z")}', delete_after=300)
await asyncio.sleep(300)
await message.delete()
except discord.NotFound:
pass
elif message.content.startswith('$hello'):
await message.channel.send('Hello!', delete_after=300)
await asyncio.sleep(300)
await message.delete()
try:
await message.channel.send('Hello!', delete_after=300)
await asyncio.sleep(300)
await message.delete()
except discord.NotFound:
pass
elif message.content.lower().startswith('good bot'):
await message.channel.send('Thanks. Good human.')
except BaseException as error:
Expand Down
9 changes: 6 additions & 3 deletions src/soup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
async def on_message(message, client, conf):
if message.content.startswith("$soup"):
if not message.channel.name in conf.soup_channels:
await message.channel.send('Please use the right channel :slight_smile:', delete_after=300)
await asyncio.sleep(300)
await message.delete()
try:
await message.channel.send('Please use the right channel :slight_smile:', delete_after=300)
await asyncio.sleep(300)
await message.delete()
except discord.NotFound:
pass
return
args = message.content.split()
cat = 'top'
Expand Down

0 comments on commit 1c59755

Please sign in to comment.