Application Commands¶
Application commands are recommended to be subclassed, but there’s always a decorator for those who dont like that.
ApplicationCommand¶
- acord.ext.application_commands.ApplicationCommand(*, conn: Any = None, application_id: acord.models.Snowflake, id: acord.models.Snowflake, name: str, description: str, version: str, type: Optional[acord.ext.application_commands.types.ApplicationCommandType] = ApplicationCommandType.CHAT_INPUT, guild_id: Optional[acord.models.Snowflake] = None, default_permission: Optional[bool] = True, options: Optional[List[acord.ext.application_commands.option.SlashOption]] = []) None[source]¶
ApplicationCommandOptionType¶
ApplicationCommandType¶
AutoCompleteChoice¶
GenericApplicationOption¶
- acord.ext.application_commands.GenericApplicationOption(*, type: acord.ext.application_commands.types.ApplicationCommandOptionType, name: str, description: str, choices: Optional[List[acord.ext.application_commands.option.ApplicationChoice]] = [], required: Optional[bool] = False, options: Optional[List[acord.ext.application_commands.option.GenericApplicationOption]] = [], channel_types: Optional[List[acord.bases.flags.channels.ChannelTypes]] = [], min_value: Optional[int] = None, max_value: Optional[int] = None, autocomplete: Optional[bool] = None) None[source]¶
GenericModelCommand¶
- acord.ext.application_commands.GenericModelCommand(*, name: str, type: acord.ext.application_commands.types.ApplicationCommandType, default_permission: Optional[bool] = True, guild_ids: Optional[List[int]] = None, overwrite: bool = False, extend: bool = True) None[source]¶
Identifier for all user defined slash commands, e.g. classes such as SlashBase.
MessageCommand¶
- acord.ext.application_commands.MessageCommand(*, name: str, type: acord.ext.application_commands.types.ApplicationCommandType, default_permission: Optional[bool] = True, guild_ids: Optional[List[int]] = None, overwrite: bool = False, extend: bool = True) None[source]¶
User commands are commands that can be ran by right clicking a message
They follow the same structure as slash commands and parameters, which can be found here at
SlashCommands.Callback Function
Callback function with message have the following signiture:
[
Interaction,Message]Note
Message may be the ID if cannot be fetched from cache
SlashBase¶
- acord.ext.application_commands.SlashBase(*, name: str, description: str, options: Optional[List[acord.ext.application_commands.option.SlashOption]] = [], default_permission: Optional[bool] = True, guild_ids: Optional[List[int]] = None, overwrite: bool = False, extend: bool = True) None[source]¶
Base class for creating slash commands.
Guidance
When creating slash commands you have 2 options, initialise this class normally (ex1). Or subclass it and add your attrs through:
class variables
direct call to super().__init__
Note
All args can be passed through the init subclass apart from,
overwriteandextend, read below for further guidance.Note
Max 25 options
Entire slash commands values must be less then 4k characters, (Dont panic this is handled for you!)
Name must be under 32 characters
Description must be under 100 characters
For a more clearer example make sure to check out the examples in the github repo.
Valid on_call names
on_call’s can be registered directly from creating the class or
SlashBase.set_call().Below they are represented as a list, were each element is the function signiture
- callback: [
Interaction, **options]Called when command is used, must be provided
- on_error: [
Interaction, exc_info]Called when an error occurs during handling of command.
- Parameters
arguments (All values from attributes are considered) –
:param : :param and will be used to create the model.: :param extend: Whether to extend attributes if they were provided twice,
doesn’t check if they are the same! Defaults to
True.
- Parameters
overwrite (
bool) – Whether to overwrite this command if it already exists, defaults toFalse.subclassing (When using args whilst) –
:param : :param
extendbecomesextendable: :param andoverwritebecomesoverwritable.:
SlashOption¶
- acord.ext.application_commands.SlashOption(*, type: acord.ext.application_commands.types.ApplicationCommandOptionType, name: str, description: str, choices: Optional[List[acord.ext.application_commands.option.ApplicationChoice]] = [], required: Optional[bool] = False, options: Optional[List[acord.ext.application_commands.option.GenericApplicationOption]] = [], channel_types: Optional[List[acord.bases.flags.channels.ChannelTypes]] = [], min_value: Optional[int] = None, max_value: Optional[int] = None, autocomplete: Optional[bool] = None) None[source]¶
Used for validating options in slash commands. This class should be used instead of GenericApplicationOption.
Rules: * A SlashOption which is acting as a group may not have another group within it * autocomplete must be
Falsewhen choices is provided * Must be less then 25 choices
UDAppCommand¶
UserCommand¶
- acord.ext.application_commands.UserCommand(*, name: str, type: acord.ext.application_commands.types.ApplicationCommandType, default_permission: Optional[bool] = True, guild_ids: Optional[List[int]] = None, overwrite: bool = False, extend: bool = True) None[source]¶
User commands are commands that can be ran by right clicking a user
They follow the same structure as slash commands and parameters, which can be found here at
SlashCommands.Callback Function
Callback function with user have the following signiture:
[
Interaction,User]Note
User may be the ID if cannot be fetched from cache
autocomplete¶
- acord.ext.application_commands.autocomplete(*options: str, dev_handle: bool = False, cls: Optional[acord.ext.application_commands.slash.SlashBase] = None, on_error: Optional[Callable[[...], Coroutine[Any, Any, Any]]] = None) Callable[[...], Coroutine[Any, Any, Any]][source]¶
Decorator for adding handlers for autocompleting parameters
- Parameters
options (
str) – Names of option to handle auto completes for, use*to handle any optiondev_handle (
bool) – Whether this field will be responded to within the classcls (
SlashBase) – Your command object which this autocomplete should be assigned to, this is not needed unless your adding them to commands generated via decorators.on_error (Callable[..., Coroutine[Any, Any, Any]]) – A coro which will be called when an error occurs