-
I'm trying to implement custom errors in checks by having raises inside of them like so: # in modules/checks.py
from discord.ext.commands import Context, check
def is_developer():
def predicate(ctx: Context):
if not ctx.author.id == (censored):
raise AccessDenied(ctx.invoked_with)
return True
return check(predicate) # in modules/exceptions.py
class AccessDenied(Exception):
def __init__(self, action:str=None) -> None:
self.action = action
super().__init__('You do not have sufficient permissions to {0}'.format('perform this action.' if not action else f'"{action}".')) however the error is caught by (the file in which i want error handling to happen is my main.py file, and these are also prefix-based commands (not app based)) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You use For your custom exception you should derive |
Beta Was this translation helpful? Give feedback.
You use
sys.exc_info
as documented:For your custom exception you should derive
CommandError
instead so it goes to the appropriate events, as documented here.