Bot API Reference#

The bot class responsible for handling all the commands and events in this handler.

Bot#

class dawn.Bot(token: str, *, default_guilds: ~typing.Optional[~typing.Sequence[int]] = None, purge_extra: bool = False, allow_color: bool = True, banner: str | None = 'dawn', executor: ~typing.Optional[~concurrent.futures._base.Executor] = None, force_color: bool = True, cache_settings: ~typing.Optional[~hikari.impl.config.CacheSettings] = None, intents: ~hikari.intents.Intents = <Intents.ALL_UNPRIVILEGED: 98045>, auto_chunk_members: bool = True, logs: ~typing.Union[None, int, str, ~typing.Dict[str, ~typing.Any]] = 'INFO', max_rate_limit: float = 300, max_retries: int = 3, proxy_settings: ~typing.Optional[~hikari.impl.config.ProxySettings] = None, rest_url: ~typing.Optional[str] = None)[source]#

The handler’s Bot class. This is a subclass of GatewayBot with all the features of the parent class supported.

Parameters
  • token (str) – The bot token for your application.

  • default_guilds (Optional[int]) – Default guilds in which the commands will be added.

  • purge_extra (bool) – Commands not bound with this class get deleted if set to True.

add_extension(extension: Extension, /) None[source]#

Adds an extension to the bot.

Parameters

extension (Extension) – The extension to be loaded.

Raises

ValueError – The extension provided wasn’t dervied from Extension class.

add_slash_command(command: SlashCommand) None[source]#

Add a slash command to the bot’s bucket.

Parameters

command (SlashCommand) – The slash command to be added to bucket.

add_slash_group(group: SlashGroup) None[source]#

Add a slash command group to bot’s bucket.

Parameters

group (SlashGroup) – The group to be added.

property extensions: Mapping[str, Extension]#

List of all extensions.

get_extension(name: str, /) dawn.extensions.Extension | None[source]#

Get a loaded extension object using it’s name.

Parameters

name (str) – Name of the extension.

get_slash_command(name: str, /) dawn.commands.slash.command.SlashCommand | None[source]#

Gets a SlashCommand by its name.

Parameters

name (str) – Name of the command.

get_slash_context(event: InteractionCreateEvent) SlashContext[source]#

Wrap an InteractionCreateEvent into a SlashContext class.

async invoke_slash_command(event: InteractionCreateEvent, command: dawn.commands.slash.command.SlashCommand | dawn.commands.slash.groups.SlashGroup) None[source]#

Executes a processed SlashCommand.

Parameters
  • event (hikari.InteractionCreateEvent) – The event related to this call.

  • command (SlashCommand) – The slash command to process.

load_module(module_path: str, /) None[source]#

Loads a module and calls the load function of the module.

Parameters

module_path (str) – Path to the module.

async process_slash_commands(event: InteractionCreateEvent, /) None[source]#

Filters and processes the slash command interactions.

Parameters

event (InteractionCreateEvent) – The event related to this call.

slash(command: SlashCommand) SlashCommand[source]#

Use this decorator to add a slash command to the bot.

Example

>>> import dawn
>>>
>>> bot = dawn.Bot("TOKEN")
>>>
>>> @bot.slash
>>> @dawn.slash_command("ping")
>>> async def ping(context: dawn.SlashContext) -> None:
>>>     await context.create_response("pong!")
>>>
>>> bot.run()
property slash_commands: Mapping[str, SlashCommand]#

Mapping for slash command names to SlashCommand objects.

property slash_groups: Mapping[str, SlashGroup]#

Mapping for slash group names to SlashGroup objects.