Using a Plugin
To use a plugin, add it to yourdjs.config.ts. You can also provide specific configuration for the plugin.
[djs.config.ts]
Creating a Plugin
You can create your own plugins by using thedefinePlugin helper from @djs-core/runtime.
[my-plugin.ts]
Plugin Lifecycle Hooks
setup(client, config): Called when the bot starts, before it logs into Discord. Returns an optional extension object.onReady(client, config, extension): Called after the bot is fully ready.
Why use plugins?
- Reusability: Share common logic (e.g., database handling, logging) across multiple bots.
- Modularity: Keep your core bot code clean by offloading specific features to plugins.
- Type Safety: When using
defineConfig, plugins and their configurations are fully typed.