#Disable the cooldown default message

1 messages · Page 1 of 1 (latest)

spice schooner
#

So I just want to format my own cooldown message when reading from interactions.error.CommandOnCooldown instead of the default message, how can I do that?

prisma houndBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

ancient heron
#

You could listen to error event and override from it, here what I've did:

class BotEvents(ipy.Extension): 
     """Bot events""" 
  
     @ipy.listen(disable_default_listeners=True) 
     async def on_command_error(self, event: CommandError): 
         """Handle command errors""" 
         if isinstance(event.error, ipy.errors.CommandOnCooldown): 
             emoji_id = re.search(r"<a?:\w+:(\d+)>", EMOJI_FORBIDDEN).group(1) 
             now = time() 
             remaining = now + event.error.cooldown.get_cooldown_time() 
             embed = ipy.Embed( 
                 author=ipy.EmbedAuthor( 
                     name="Forbidden action", 
                 ), 
                 title="You are on cooldown", 
                 description=f"Try again <t:{int(remaining)}:R>", 
                 color=0xFF0000, 
             ) 
             embed.set_thumbnail( 
                 url=f"https://cdn.discordapp.com/emojis/{emoji_id}.webp" 
             ) 
             await event.ctx.send(embed=embed, ephemeral=True)
spice schooner
#

Hmm, is it possible to use that in on_error instead?

#

I use on_error instead of on_command_error since I want to capture all exceptions, not just command.

ancient heron
ripe night
#

The default CommandCooldown happens inside command_error, so you'd have to override that event.
You can listen to both though, nobody's stopping you

lean cosmos
#

well, wait

#

all errors in on_command_error can get passed down to on_error if you want to do that