SlashCommand API Reference#

Classes related to the library’s slash command ecosystem.

Option#

class dawn.Option(name: str, description: str = '...', *, type: ~typing.Any = <class 'str'>, required: bool = True, channel_types: ~typing.Optional[~typing.Sequence[hikari.channels.ChannelType | int]] = None, autocomplete: bool = False, min_value: ~typing.Optional[~typing.Union[int, float]] = None, max_value: ~typing.Optional[~typing.Union[int, float]] = None)[source]#

Option constructor for slash commands. This is a subclass of hikari.CommandOption

Parameters
  • name (str) – Name of the option.

  • description (str) – Description of the option, defaults to

  • type (Any) –

    Any of these classes can be used for the following option types.

    hikari.User: hikari.OptionType.USER

    hikari.Member: hikari.OptionType.USER

    hikari.Role: hikari.OptionType.ROLE

    hikari.GuildChannel: hikari.OptionType.CHANNEL

    hikari.Attachment: hikari.OptionType.ATTACHMENT

    bool: hikari.OptionType.BOOLEAN

    int: hikari.OptionType.INTEGER

    float: hikari.OptionType.FLOAT

    str: hikari.OptionType.STRING

  • required (bool) – Weather the argument is a required or optional.

  • channel_types (Optional[Sequence[Union[hikari.ChannelType, int]]) – The channel types to check if the type was hikari.GuildChannel

  • autocomplete (bool) – Is autocomplete enabled for this option?.

SlashCommand#

class dawn.SlashCommand(name: str, description: str, guild_ids: Optional[Sequence] = None, options: Tuple[Option, ...] = ())[source]#

This object represents a discord slash command.

Parameters
  • name (str) – Name of the command.

  • description (str) – Description of the command.

  • guild_ids (Sequence[int]) – List of guild ids this command is bound to.

  • options (Tuple[Option, ...]) – A tuple of command options.

autocomplete(option_name: str, /) Callable[[Callable[[AutocompleteInteraction, AutocompleteInteractionOption], Awaitable[Any]]], None][source]#

Add autocomplete for a command option.

Parameters

option_name (str) – Name of the option this autocomplete is for.

Example

>>> @bot.slash
>>> @dawn.slash_command(options=[dawn.Option("color", autocomplete=True)])
>>> async def colors(ctx: dawn.SlashContext, color: str) -> None:
>>>     await ctx.create_response(f"{ctx.author} chose {color}")
>>>
>>> @colors.autocomplete("color")
>>> async def ac_color(inter: hikari.AutocompleteInteraction, option: hikari.AutocompleteInteractionOption) -> list[hikari.CommandChoice| str]:
>>>       return [
>>>         "red",
>>>         hikari.CommandChoice(name="blue", value="blue")
>>>     ]
property description: str#

Description fo the command.

property extension: Extension | None#

Extension which is binded with this command

property guild_ids: Sequence[int]#

Sequence of guild_ids this command is bound to.

property name: str#

Name of the command.

property options: Tuple[Option, ...]#

Tuple of command options

SlashGroup#

class dawn.SlashGroup(name: str, description: str = 'No Description Provided', *, guild_ids: Optional[Sequence[int]] = None)[source]#

Represents a slash command group.

property description: str#

Description fo the group.

property extension: Extension | None#

Extension which is binded with this group

property guild_ids: Sequence[int]#

Sequence of guild_ids this group is bound to.

property name: str#

Name of the group.

subcommand(*, name: Optional[str] = None, description: Optional[str] = None, options: Optional[List[Option]] = None) Callable[[Callable[[...], Any]], SlashSubCommand][source]#

This decorator is used to create slash subcommands.

Parameters
  • name (str) – Name of the subcommand.

  • description (str) – Description of the subcommand.

  • options (Option) – Options for the subcommand.

subgroup(*, name: str, description: Optional[str] = None) SlashSubGroup[source]#

Add a subgroup to the existing group.

Parameters
  • name (str) – Name of the subgroup.

  • description (str) – Description of the subgroup.

SlashSubCommand#

class dawn.SlashSubCommand(name: str, description: str, options: List[Option])[source]#

This class represents a slash sub-command.

autocomplete(option_name: str, /) Callable[[Callable[[AutocompleteInteraction, AutocompleteInteractionOption], Awaitable[Any]]], None][source]#

Add autocomplete for a subcommand option.

Parameters

option_name (str) – Name of the option this autocomplete is for.

Example

>>> group = dawn.SlashGroup(name="Test")
>>>
>>> bot.add_slash_group(group)
>>>
>>> @group.subcommand(options=[dawn.Option("number", type=int, autocomplete=True)])
>>> async def command(ctx: dawn.SlashContext, number: int) -> None:
>>>     await ctx.create_response(number)
>>>
>>> @command.autocomplete("number")
>>> async def ac_number(inter: hikari.AutocompleteInteraction,opt= hikari.AutocompleteInteractionOption) -> list[int| hikari.CommandChoice]:
>>>     return [1,2,3,4 , hikari.CommandChoice(name="five", value=5)]
property description: str#

Description of the subcommand.

property name: str#

Name of the subcommand.

property options: List[Option]#

Options for the subcommand

SlashSubGroup#

class dawn.SlashSubGroup(name: str, description: str)[source]#
property description: str#

Description of the sub command group

property name: str#

Name of the subcommand group

subcommand(*, name: Optional[str] = None, description: Optional[str] = None, options: Optional[List[Option]] = None) Callable[[Callable[[...], Any]], SlashSubCommand][source]#

This decorator is used to create slash subcommands.

Parameters
  • name (str) – Name of the subcommand.

  • description (str) – Description of the subcommand.

  • options (Option) – Options for the subcommand.

property subcommands: List[SlashSubCommand]#

SubCommands in the group