The Bot
At the core of your bot is the ExtensibleBot
class. This class is the most important part of Kord Extensions, as the jumping-off point for your bot. Among other things, it dispatches commands and event handlers, and keeps track of extensions. It also contains several useful APIs.
Creating a Bot
Before you do anything else, you'll need to create a bot via the ExtensibleBot
factory function. This function is a builder that always requires a Discord bot token parameter. The builder can then be used to configure the bot.
Configuration
The ExtensibleBot
builder contains your bot's configuration, which is split up into a series of builder functions. For more information on what options are available and how to use them, see the Configuration section.
ExtensibleBot API
The ExtensibleBot
type exposes a number of APIs that may be helpful for advanced use-cases. If you'd like to use them, you can get access to the current object via Koin ⏳.
Functions
Function | Parameters | Description |
---|---|---|
| Stop the bot by shutting down the Kord instance and stopping the Kord Extensions Koin context. A bot that has been closed can no longer be used, and a new bot must be constructed. This function exists to close and clean up the bot, so a new one may be constructed. | |
|
| Manually subscribe to an event. Most developers will never need to use this directly. If you can register an event handler in an Extension, then that's a far better option. |
| Send an event to the handlers listening for it. You can use this to send a custom event to be acted upon elsewhere. If possible, use the | |
| Start up the bot and log into Discord. Blocks the current coroutine until the bot is shut down. | |
| Start up the bot and log into Discord. Launches the | |
| Stop the bot by telling the Kord instances to log out of Discord. This will leave the Koin context intact, so the bot may be restarted later. |
The following functions are all related to extension management.
Function | Parameters | Description |
---|---|---|
|
| Manually install an extension by constructing and loading it. This is only exposed for advanced use-cases, and you should prefer loading extensions via the bot's configuration instead where possible. |
|
| Find the first loaded extension that is an instance of (or extend) |
|
| Find all loaded extensions that are instances of (or extend) |
|
| Reload a previously loaded extension by name. If the extension isn't found or is already loaded, nothing happens. |
|
| Unload and remove a registered extension by name. This will prevent the extension from being loaded in the future. If the extension isn't found or loaded, nothing happens. |
|
| Unloaded a currently installed extension by name. If the extension isn't found or loaded, nothing happens. |
Properties
Property | Type | Description |
---|---|---|
|
| The builder used when configuring the bot. Provided as a way to access the user-supplied configuration, excluding the bot token. |
|
| Shared flow which combined the events sent by both Kord and Kord Extensions. |
|
| Mutable shared flow used for event publishing. For most use-cases, you should use the |