Line 41 was causing problems, needs to be moved into CommandOnCooldown, Added... #11

Merged
Rich merged 1 commits from 3-r0b3bot-does-not-handle-homeassistant-api-failure-gracefully into master 2019-11-22 14:11:27 +00:00
+6 -1
View File
@@ -38,11 +38,16 @@ hassapi = remote.API(HASS_IP_ADDRESS, HASS_API_KEY)
@bot.event
async def on_command_error(ctx, error):
print(error.retry_after)
if isinstance(error, commands.CommandOnCooldown):
#msg = 'This command is ratelimited, please try again in {:.2f}s'.format(error.retry_after)
seconds = round(error.retry_after,1)
print(f" - Error, user tried to use command while in cooldown (wait is: {seconds}")
await ctx.send(f"This command is ratelimited per user, please try again in {seconds}s")
if isinstance(error, commands.CommandInvokeError):
print(" - ERROR: encountered 'CommandInvokeError'")
print(f" - Dumping error: {error}")
await ctx.send("Error, unable to complete your request.")
await ctx.send()
else:
print('Oopsie, I found an error...')
print(f"Error: {error}")