Skip to content

Commands API

Command Interactions

Note

The following classes come from the discord.parts.command module.


SlashCommand dataclass

Bases: DataModel

name: str instance-attribute

description: str instance-attribute

options: list[_CommandOption] = field(default_factory=list) class-attribute instance-attribute

add_option

Add an option to this slash command.

Parameters:

  • command_type (Literal['String', 'Integer', 'Boolean', 'User', 'Channel', 'Role', 'Mentionable', 'Number', 'Attachment']) –

    input type for the option

  • name (str) –

    name of the option

  • description (str) –

    description for the option

  • required (bool, default: False ) –

    if the option is required. Defaults to False.

Returns:


CommandOptionTypes

Slash command option input types.

STRING = 3 class-attribute instance-attribute

string (text)

INTEGER = 4 class-attribute instance-attribute

integer (whole)

BOOLEAN = 5 class-attribute instance-attribute

boolean (true/false)

USER = 6 class-attribute instance-attribute

user pangination

CHANNEL = 7 class-attribute instance-attribute

channel pangination

ROLE = 8 class-attribute instance-attribute

role pangination

MENTIONABLE = 9 class-attribute instance-attribute

any pangination (role, channel, user)

NUMBER = 10 class-attribute instance-attribute

number (float, integer)

ATTACHMENT = 11 class-attribute instance-attribute

file upload


MessageCommand dataclass

Bases: DataModel

Represents the message command object.

name: str instance-attribute


UserCommand dataclass

Bases: DataModel

Represents the user command object

name: str instance-attribute