API Reference
Enums
DiscordPermissions
Enum representing various Discord permissions.
CREATE_INSTANT_INVITE
: Permission to create instant invites.KICK_MEMBERS
: Permission to kick members.BAN_MEMBERS
: Permission to ban members.ADMINISTRATOR
: Permission to be an administrator.MANAGE_CHANNELS
: Permission to manage channels.MANAGE_GUILD
: Permission to manage the guild.ADD_REACTIONS
: Permission to add reactions to messages.VIEW_AUDIT_LOG
: Permission to view the audit log.PRIORITY_SPEAKER
: Permission to use priority speaker.STREAM
: Permission to stream in voice channels.VIEW_CHANNEL
: Permission to view channels.SEND_MESSAGES
: Permission to send messages.SEND_TTS_MESSAGES
: Permission to send TTS messages.MANAGE_MESSAGES
: Permission to manage messages.EMBED_LINKS
: Permission to embed links in messages.ATTACH_FILES
: Permission to attach files to messages.READ_MESSAGE_HISTORY
: Permission to read message history.MENTION_EVERYONE
: Permission to mention everyone.USE_EXTERNAL_EMOJIS
: Permission to use external emojis.VIEW_GUILD_INSIGHTS
: Permission to view guild insights.CONNECT
: Permission to connect to voice channels.SPEAK
: Permission to speak in voice channels.MUTE_MEMBERS
: Permission to mute members in voice channels.DEAFEN_MEMBERS
: Permission to deafen members in voice channels.MOVE_MEMBERS
: Permission to move members between voice channels.USE_VAD
: Permission to use voice activity detection.CHANGE_NICKNAME
: Permission to change nickname.MANAGE_NICKNAMES
: Permission to manage nicknames.MANAGE_ROLES
: Permission to manage roles.MANAGE_WEBHOOKS
: Permission to manage webhooks.MANAGE_EMOJIS
: Permission to manage emojis.
Event
Enum representing various events in the application.
CommandNotFound
: Event triggered when a command is not found.ArgumentCastingError
: Event triggered when there is an error casting an argument.CheckFailure
: Event triggered when a check fails.CommandOnCooldown
: Event triggered when a command is on cooldown.MissingRequiredArgument
: Event triggered when a required argument is missing.TooManyArguments
: Event triggered when too many arguments are passed.BadArgument
: Event triggered when an argument is invalid.ConversionError
: Event triggered when an error occurs during conversion.CommandInvokeError
: Event triggered when an error occurs during command invocation.
Exceptions
CommandNotFound
Exception raised when a command is not found.
ExceptionDuringCommand
Exception raised when there is an exception during command execution.
ArgumentCastingError
Exception raised when an error occurs during argument casting.
CommandOnCooldown
Exception raised when a command is on cooldown.
MissingRequiredArgument
Exception raised when a required argument is missing.
InvalidPermissions
Exception raised when a user does not have the required permissions to execute a command.
Handler Class
The Handler
class processes commands and events in a Discord bot.
__init__(self, app: Client, prefix: Union[str, List[str]], case_insensitive: bool = False)
Initialize the botcontroller.
Parameters:
- app (Client): The Discord client instance.
- prefix (Union[str, List[str]]): The prefix or list of prefixes for commands.
- case_insensitive (bool): Whether command matching is case insensitive.
@command(name: str, description: str, aliases: List[str] = [])
Decorator to register a command.
Parameters:
- name (str): The name of the command.
- description (str): The description of the command.
- aliases (List[str]): The list of aliases for the command.
Injected arguments:
- message (Message): The Discord message containing the command.
@event(event_name: str)
Decorator to register an event botcontroller.
Parameters:
- event_name (Union[Str | botcontroller.Event]): The name of the event to handle.
Injected arguments:
- message [conditional on event type] (discord.Message): The Discord message containing the command.
- command [conditional on event type] (botcontroller.Command): The invoked command.
- argument [conditional on event type] (str): The argument that caused the event to be invoked.
- exception [conditional on event type] (Exception): The exception that was raised.
- permission_type [conditional on event type] (str['USER' | 'CHANNEL' | 'GUILD' | 'ROLE' | 'PERMISSION']): The type of Permission check that errored.
- missing_attribute (discord.Role | discord.Channel | discord.Guild | discord.Permissions | discord.User): The object of the failed permission.
Events
CommandNotFound
Handles the event when an error is raised during command invocation.
- message (discord.Message): The message object received during invocation.
ArgumentCastingError
Handles the event when there is an error casting an argument.
- message (discord.Message): The message object received during invocation.
- command (botcontroller.Command): The command object in which the error occured.
- argument (str): The argument that caused the error.
ExceptionDuringCommand
Handles the event when there is an exception during command execution.
- message (discord.Message): The message object received during invocation.
- command (botcontroller.Command): The command object in which the exception occured.
- error (Exception): The exception that was raised.
InvalidPermissions
Handles the event when a user does not have the required permissions to execute a command.
- permission_type (List[str]): The list of permissions required to execute the command.
- message (discord.Message): The message object received during invocation.
- missing_attribute (discord.Role | discord.Channel | discord.Guild | discord.Permissions | discord.User): The object of the failed permission.