fix error handling

This commit is contained in:
xenofem 2020-07-29 21:16:36 -04:00
parent f59d52577f
commit b74d9a9188

View file

@ -96,7 +96,7 @@ async def delete_if_possible(channels):
for c in channels: for c in channels:
try: try:
await c.delete() await c.delete()
except: except discord.DiscordException:
pass pass
async def countdown(channel): async def countdown(channel):
@ -171,7 +171,7 @@ async def handle_guild_message(message):
await message.channel.send("looks like I'm not allowed to create voice channels :(") await message.channel.send("looks like I'm not allowed to create voice channels :(")
await delete_if_possible(pollination_channels) await delete_if_possible(pollination_channels)
return return
except discord.HTTPException as e: except discord.DiscordException as e:
exception_count += 1 exception_count += 1
if exception_count > 20: if exception_count > 20:
await message.channel.send("I'm trying to create voice channels, but something's wrong: {}".format(e)) await message.channel.send("I'm trying to create voice channels, but something's wrong: {}".format(e))
@ -189,11 +189,11 @@ async def handle_guild_message(message):
for ((a, b), c) in zip(matching, pollination_channels): for ((a, b), c) in zip(matching, pollination_channels):
try: try:
await a.move_to(c) await a.move_to(c)
except e: except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(a, e), file=sys.stderr) print('failed to move participant {}: {}'.format(a, e), file=sys.stderr)
try: try:
await b.move_to(c) await b.move_to(c)
except e: except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(b, e), file=sys.stderr) print('failed to move participant {}: {}'.format(b, e), file=sys.stderr)
await asyncio.sleep(60*3) await asyncio.sleep(60*3)
await message.channel.send('Round ending in 2 minutes {}'.format(mention_all)) await message.channel.send('Round ending in 2 minutes {}'.format(mention_all))
@ -206,7 +206,7 @@ async def handle_guild_message(message):
for u in participants: for u in participants:
try: try:
await u.move_to(main_voice_channel) await u.move_to(main_voice_channel)
except e: except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr) print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
await delete_if_possible(pollination_channels) await delete_if_possible(pollination_channels)