-
Hi, currently i already have bot wide
None of these seem to fit my use case for a bot wide hybrid command error handler, would be immensely useful if there is one and i missed it in docs. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
-
You can make a separate cog for handling the exceptions inside your Discord bot.
# cogs/exception-handler.py
import discord
from discord.ext import commands
class ExceptionHandler(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error) -> None:
pass # do your things here
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(ExceptionHandler(bot)) |
Beta Was this translation helpful? Give feedback.
-
thank you Danny and @hitblast that solved my question. |
Beta Was this translation helpful? Give feedback.
You can make a separate cog for handling the exceptions inside your Discord bot.