Commands

Manager

class CommandManager(client: HTTPClient, storage: CacheStorage, application_id: int, commands_data: dict[str, tuple[int, PartialApplicationCommand]])

Bases: BaseManager

Manager used to manage ApplicationCommand.

async fetch_all(*, guild_id: int | None = None, with_localizations: bool = True) list[ApplicationCommand]

Fetches a list of all application commands from the Discord API.

Parameters:
Raises:
get_all(*, guild_id: int | None = None) list[ApplicationCommand]

Gets a list of ApplicationCommand frok the internal cache. Can be empty if the commands are not fetched atleast once.

Parameters:

guild_id (int) – The Guild ID of the Guild for getting commands scoped by guild.

async add(command: PartialApplicationCommand, *, guild_id: int | None = None) ApplicationCommand

Adds a specific command object to the Application.

Parameters:
Raises:
async fetch(command_id: int, *, guild_id: int | None = None) ApplicationCommand

Fetches an application command from the Discord API.

Parameters:
  • command_id (int) – The ID of the command to fetch.

  • guild_id (int, optional) – The Guild ID for fetching commands if scoped by guild.

Raises:
  • NotFound – The command you tried to fetch does not exist.

  • Unauthorized – You are not authorized. Your token may be invalid.

  • HTTPException – A HTTP error occured.

async sync_all() list[ApplicationCommand]

Syncs registered commands via @Bot.command() to the Application. This will override all commands currently synced.

Raises:
async sync_bulk(commands: list[PartialApplicationCommand], *, guild_id: int | None = None) list[ApplicationCommand]

Syncs given commands to the Application. This will override all commands currently synced.

Parameters:
  • commands (list[PartialApplicationCommand]) – The new list of commands.

  • guild_id (int, optional) – The Guild ID of the Guild to PUT to if scoped by guild.

Raises:
async edit(command_id: int, *, guild_id: int, name: str = _MISSING, name_localizations: Localization | None = _MISSING, description: str = _MISSING, description_localizations: Localization | None = _MISSING, options: list[ApplicationCommandOption] = _MISSING, default_member_permissions: Permissions | None = _MISSING, nsfw: bool = _MISSING) ApplicationCommand
async edit(command_id: int, *, name: str = _MISSING, name_localizations: Localization | None = _MISSING, description: str = _MISSING, description_localizations: Localization | None = _MISSING, options: list[ApplicationCommandOption] = _MISSING, default_member_permissions: Permissions | None = _MISSING, integration_types: list[ApplicationIntegrationType] = _MISSING, contexts: list[InteractionContextType] = _MISSING, nsfw: bool = _MISSING) ApplicationCommand

Edits an application command. All parameters to this method besides command_id are optional.

Parameters:
  • command_id (int) – The ID of the command to edit.

  • guild_id (int) – The Guild ID of the Guild, if editing command scoped by guild.

  • name (str) – The name of the command.

  • name_localizations (Localization) – The localizations for the name of the command.

  • description (str) – The description of the command.

  • description_localizations (Localization) – The localizations for the description of the command.

  • options (list[ApplicationCommandOption]) – The options (parameters or sub-commands) of the command.

  • default_member_permissions (Permissions) – The default member permissions of the command.

  • integration_types (list[ApplicationIntegrationType]) – The installation contexts where the command is available.

  • contexts (list[InteractionContextType]) – The installation contexts where the command can be used.

  • nsfw (bool) – Whether the command is NSFW.

Raises:
  • NotFound – The command you tried to edit does not exist.

  • Unauthorized – You are not authorized. Your token may be invalid.

  • HTTPException – A HTTP error occured.

async delete(command_id: int, *, guild_id: int | None = None) None

Deletes an application command.

Parameters:
  • command_id (int) – The ID of the command to delete.

  • guild_id (int, optional) – The Guild ID of the Guild, if deleting a command scoped by guild.

Raises:
  • NotFound – The command you tried to edit does not exist.

  • Unauthorized – You are not authorized. Your token may be invalid.

  • HTTPException – A HTTP error occured.

Objects

class Mentionable

Bases: object

class Localization(data: LocalizationPayload)

Bases: object

id
da
de
en_gb
en_us
es_es
es_419
fr
hr
it
lt
hu
nl
no
pl
pt_br
ro
fi
sv_se
vi
tr
cs
el
bg
ru
uk
hi
th
zh_cn
ja
zh_tw
ko
class ApplicationCommandOption(data: CommandOptionPayload)

Bases: object

type
name
name_localizations
description
description_localizations
required
choices
options
channel_types
min_value
max_value
min_length
max_length
autocomplete
classmethod new(*, type: Literal[CommandOptionType.SUB_COMMAND, CommandOptionType.SUB_COMMAND_GROUP], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, options: list[ApplicationCommandOption] = _MISSING) Self
classmethod new(*, type: Literal[CommandOptionType.STRING], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, required: bool = False, choices: list[ApplicationCommandChoice] = _MISSING, min_length: int = _MISSING, max_length: int = _MISSING, autocomplete: bool = _MISSING) Self
classmethod new(*, type: Literal[CommandOptionType.INTEGER], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, required: bool = False, choices: list[ApplicationCommandChoice] = _MISSING, min_value: int = _MISSING, max_value: int = _MISSING, autocomplete: bool = _MISSING) Self
classmethod new(*, type: Literal[CommandOptionType.BOOLEAN, CommandOptionType.USER, CommandOptionType.ROLE, CommandOptionType.MENTIONABLE, CommandOptionType.ATTACHMENT], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, required: bool = False) Self
classmethod new(*, type: Literal[CommandOptionType.CHANNEL], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, required: bool = False, channel_types: list[ChannelType] = _MISSING) Self
classmethod new(*, type: Literal[CommandOptionType.NUMBER], name: str, name_localizations: Localization = _MISSING, description: str, description_localizations: Localization = _MISSING, required: bool = False, choices: list[ApplicationCommandChoice] = _MISSING, min_value: float = _MISSING, max_value: float = _MISSING, autocomplete: bool = _MISSING) Self
class ApplicationCommandChoice(data: CommandChoicePayload)

Bases: object

name
name_localizations
value
classmethod new(*, name: str, name_localizations: Localization = <mizuki._utils.Missing object>, value: str | int | float) Self
class PartialApplicationCommand(data: PartialApplicationCommandPayload, callback: CoroFunc | None)

Bases: BaseApplicationCommand

description
default_member_permissions
classmethod new(*, name: str, name_localizations: Localization = <mizuki._utils.Missing object>, description: str = <mizuki._utils.Missing object>, description_localizations: Localization = <mizuki._utils.Missing object>, options: list[ApplicationCommandOption] = <mizuki._utils.Missing object>, default_member_permissions: Permissions = <mizuki._utils.Missing object>, integration_types: list[ApplicationIntegrationType] = <mizuki._utils.Missing object>, contexts: list[InteractionContextType] = <mizuki._utils.Missing object>, type: ApplicationCommandType = ApplicationCommandType.CHAT_INPUT, nsfw: bool = False, callback: CoroFunc = <mizuki._utils.Missing object>) Self
contexts
description_localizations
integration_types
name
name_localizations
nsfw
options
type
class ApplicationCommand(data: ApplicationCommandPayload)

Bases: BaseApplicationCommand

id
contexts
description_localizations
integration_types
name
name_localizations
nsfw
options
type
description
application_id
guild_id
version
handler

Enums

class CommandOptionType(*values)
SUB_COMMAND = 1
SUB_COMMAND_GROUP = 2
STRING = 3
INTEGER = 4
BOOLEAN = 5
USER = 6
CHANNEL = 7
ROLE = 8
MENTIONABLE = 9
NUMBER = 10
ATTACHMENT = 11
class ApplicationCommandType(*values)
CHAT_INPUT = 1
USER = 2
MESSAGE = 3
PRIMARY_ENTRY_POINT = 4
class CommandHandler(*values)
APP_HANDLER = 1
DISCORD_LAUNCH_ACTIVITY = 2