Reputation: 19
I have a Discord bot running on the cloud, and when my shared IP hits the rate limit of 50 requests per second, my bot gets blocked for a while (I know, it's a terrible system but it's where I'm at). In the event that this happens, I want it to send me a message on another site. I have a way to send the message (with the Tweepy module for Twitter) that works, but nothing happens when I use the following code:
@client.event
async def on_error(ctx, error):
if isinstance(error, discord.errors.HTTPException):
#do something
Am I doing something wrong?
Upvotes: 1
Views: 2125
Reputation: 3602
Since your ratelimit can only be triggered by certain commands and you only get the message in the console afterwards it makes sense to use the on_command_error
event.
Look at the following code:
@client.event
async def on_command_error(ctx, error):
if isinstance(error, discord.HTTPException):
await ctx.send("You are ratelimited") # Send whatever you want.
Upvotes: 1