DDBKitFoundation
DDBKitFoundation is a module that provides extra utilities to cover generic boilerplate work, in the form of many extensions. It offers a number of pre-built interactive commands for end-users to discover your bot and easily configure it. It also offers an easy-to-use way of configuration since handling configuration is done by the extension itself, you just need to provide the available properties for configuration and read configuration values as needed.
Setup - Configurator
To use DDBKitFoundation, you need to import the module into your project.
// Remember to use @_spi to access extensions.@_spi(Extensions) import DDBKitFoundation
Register the Configurator
extension in your bot app.
@mainstruct MyNewBot: DiscordBotApp { init() async { // ... }
func boot() async throws { // we pass in the configuration template type to the configurator instance let configExtension = Configurator(guildConfiguation: GuildConfigTemplate.self) RegisterExtension(configExtension) }}
// ... elsewhere
struct GuildConfigTemplate: ConfigTemplate { @Config(name: "prefix", description: "The prefix for the bot", initialValue: "!") var prefix: String}
And with that, basic setup is done! Configurator
has added /config guild
to your bot,
which allows members of a guild with the Manage Server permission to configure the bot’s prefix.
The kicker is that you don’t need to worry about the configuration process or storage, you can just read the configuration values as needed during the bot’s lifecycle.
SOON!
DDBKitFoundation will have more features in the future!