Cog
CogMeta are equally valid here.
Class Parameters
The cog name. By default, it is the name of the class with no modification. Pass this as a keyword argument during class creation:
A dictionary of attributes to apply to every command inside this cog. The dictionary is passed into the
Command (or its subclass) options at __init__. If you specify attributes inside the command attribute in the class, it will override the one specified inside this attribute.Properties
Returns the cog’s specified name, not the class name.
Returns the cog’s description, typically the cleaned docstring.
A dictionary of (name, function) event handler pairs that are defined in this cog.
Methods
get_commands
Commands that are defined inside this cog.
Note: This does not include subcommands.
Returns: List[Command] - The commands in this cog.
walk_commands
Special Methods
These are special methods that can be overridden in your cog to provide custom behavior.cog_unload
bot_check_once
Bot.check_once() check.
This function can be a coroutine and must take a sole parameter, ctx, to represent the Context.
bot_check
Bot.check() check.
This function can be a coroutine and must take a sole parameter, ctx, to represent the Context.
cog_check
@commands.check for every command and subcommand in this cog.
This function can be a coroutine and must take a sole parameter, ctx, to represent the Context.
cog_command_error
event_command_error except only applying to the commands inside this cog.
Command error handlers are raised in a specific order. Returning False in any of them will invoke the next handler in the chain:
- The local command error handler is called (Handler specified by
Command.error) - The local cog command error handler is called (This method)
- All
event_command_error()handlers are called simultaneously
ctx(Context): The invocation context where the error happened.error(CommandError): The error that happened.
cog_before_invoke
Command.before_invoke().
This must be a coroutine.
Parameters:
ctx(Context): The invocation context.
cog_after_invoke
Command.after_invoke().
This must be a coroutine.
Parameters:
ctx(Context): The invocation context.
Decorator
@Cog.event
- Use
@Cog.event()and have the function name match the event name (with or without theevent_prefix) - Use
@Cog.event('event_name')to explicitly specify the event name
TypeError: The decorated function is not a coroutine.TypeError: Event is not specified as argument or function name with event prefix.