Skip to content

Commands API

Command Interactions

Note

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


SlashCommand dataclass

Bases: DataModel

Represents the slash command object.

name: str = None class-attribute instance-attribute

Name of the command.

description: str = None class-attribute instance-attribute

Description of the command.

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

Parameters or options for the command.

type: int = field(init=False, default=(CommandTypes.CHAT_INPUT)) class-attribute instance-attribute

Command type. Always CommandTypes.CHAT_INPUT for this class. See CommandTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

CommandOption dataclass

Bases: DataModel

Option for a slash command.

type: int = None class-attribute instance-attribute

Type of option. See CommandOptionTypes.

name: str = None class-attribute instance-attribute

Name of option.

description: str = None class-attribute instance-attribute

Description of option.

required: bool = False class-attribute instance-attribute

Whether this option is required. Defaults to False.

choices: list[CommandOptionChoice] = field(default_factory=list) class-attribute instance-attribute

Choices for the user to pick from, max 25. Only valid for STRING, INTEGER, NUMBER option types.

autocomplete: bool = False class-attribute instance-attribute

Whether autocomplete interactions are enabled for this option. Defaults to False.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

CommandOptionTypes

Slash command option input types.

STRING = 3 class-attribute instance-attribute

string (text)

INTEGER = 4 class-attribute instance-attribute

integer (Any integer between -2^53+1 and 2^53-1)

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 (category and channels)

ROLE = 8 class-attribute instance-attribute

role pangination

MENTIONABLE = 9 class-attribute instance-attribute

any pangination (role and user)

NUMBER = 10 class-attribute instance-attribute

number (Any double between -2^53 and 2^53)

ATTACHMENT = 11 class-attribute instance-attribute

file upload (See Attachment)


MessageCommand dataclass

Bases: DataModel

Represents the message command object.

name: str = None class-attribute instance-attribute

Name of the command.

type: int = field(init=False, default=(CommandTypes.MESSAGE_COMMAND)) class-attribute instance-attribute

Command type. Always CommandTypes.MESSAGE_COMMAND for this class. See CommandTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


UserCommand dataclass

Bases: DataModel

Represents the user command object.

name: str = None class-attribute instance-attribute

Name of the command.

type: int = field(init=False, default=(CommandTypes.USER_COMMAND)) class-attribute instance-attribute

Command type. Always CommandTypes.USER_COMMAND for this class. See CommandTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


CommandTypes

CHAT_INPUT = 1 class-attribute instance-attribute

USER_COMMAND = 2 class-attribute instance-attribute

MESSAGE_COMMAND = 3 class-attribute instance-attribute