Skip to content

discohook.command

Classes

Functions

ApplicationCommand

discohook.command.ApplicationCommand

Discord application command class.

Arguments

  • name (str): Name of the command.
  • description (str | None): Description of the command. Does not apply to user and message commands.
  • options (List[Option] | None): Options of the command. Does not apply to user & message commands.
  • nsfw (bool): Whether the command is nsfw. Defaults to False.
  • permissions (List[Permission] | None): Permissions of the command. Defaults to None.
  • type (ApplicationCommandType): Type of the command. Defaults to slash commands.
  • integration_types (List[ApplicationIntegrationType] | None): Integrations of the command. Defaults to None.
  • contexts (List[InteractionContextType] | None): Contexts of the command. Defaults to None.

Method Index

Methods

check

python
check(self)

Decorator that adds a check to the command.

on_autocomplete

python
on_autocomplete(self, coro: Callable[[ForwardRef('Interaction'), Any], Coroutine[Any, Any, Any]])

Decorator to register a callback for the command's autocomplete options.

on_error

python
on_error(self)

Decorator that adds an error handler to a specific command or component.

subcommand

python
subcommand(self, name: str | None = None, *, description: str | None = None, options: List[discohook.option.Option] | None = None)

Decorator to register a subcommand for the command.

Arguments

  • name (str): Name of the subcommand.
  • description (str): Description of the subcommand. If not provided, it will be resolved from the callback's name.
  • options (List[Option] | None): Options of the subcommand.

Raises

  • TypeError: If the callback is not a coroutine.

to_dict

python
to_dict(self) -> Dict[str, Any]

Converts the command to a dictionary. Not intended for use by end-users.

Returns

  • Type: dict
    • Dictionary of the command object.

SubCommand

discohook.command.SubCommand

Discord application command subcommand class.

Arguments

  • name (str): Name of the subcommand.
  • description (str): Description of the subcommand.
  • options (List[Option] | None): Options of the subcommand.
  • handler (Handler): Handler for the subcommand.

Method Index

Methods

check

python
check(self)

Decorator that adds a check to the command.

on_autocomplete

python
on_autocomplete(self, coro: Callable[[ForwardRef('Interaction'), Any], Coroutine[Any, Any, Any]])

Decorator to register a callback for a subcommand's autocomplete options.

on_error

python
on_error(self)

Decorator that adds an error handler to a specific command or component.

SubCommandGroup

discohook.command.SubCommandGroup

Barely need it.

message

Qualified Name: discohook.command.message

Signature

python
message(name: str | None = None, *, nsfw: bool = False, permissions: List[discohook.permission.Permission] | None = None, guild_id: str | None = None, integration_types: List[discohook.enums.ApplicationIntegrationType] | None = None, contexts: List[discohook.enums.InteractionContextType] | None = None)

Decorator to create a message command with its callback.

slash

Qualified Name: discohook.command.slash

Signature

python
slash(name: str | None = None, *, description: str | None = None, options: List[discohook.option.Option] | None = None, nsfw: bool = False, permissions: List[discohook.permission.Permission] | None = None, guild_id: str | None = None, integration_types: List[discohook.enums.ApplicationIntegrationType] | None = None, contexts: List[discohook.enums.InteractionContextType] | None = None)

Decorator to create a slash command with its callback.

user

Qualified Name: discohook.command.user

Signature

python
user(name: str | None = None, *, nsfw: bool = False, permissions: List[discohook.permission.Permission] | None = None, guild_id: str | None = None, integration_types: List[discohook.enums.ApplicationIntegrationType] | None = None, contexts: List[discohook.enums.InteractionContextType] | None = None)

Decorator to create a user command with its callback.