#Disable the cooldown default message
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
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)
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.
Tbh, I didn't use it on my prod (as I wanted more verbose), but I guess you can check if the err event is CommandOnCooldown in isinstance?
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