JDAService
Interfaced service to be implemented by the service which creates a JDA instance.
This has many advantages:
Checking gateway intents, cache flags, and member cache requirements for event listeners and event waiters
Conditionally enabling services based on gateway intents (@RequiredIntents), cache flags, and member cache
Starting JDA when every other service is ready
Usage
Register your instance as a service with @BService.
Example:
@BService
class Bot(private val config: Config) : JDAService() {
// Default intents + MESSAGE_CONTENT
override val intents: Set<GatewayIntent> = defaultIntents(GatewayIntent.MESSAGE_CONTENT)
override val cacheFlags: Set<CacheFlag> = enumSetOf()
override fun createJDA(event: BReadyEvent, eventManager: IEventManager) {
// Read the docs on what this does
lightSharded(config.token, ...) {
...
}
}
}
Spring support
Spring users must set their gateway intents and cache flags using properties, named jda.intents
and jda.cacheFlags
respectively, also available in JDAConfiguration.
See also
Properties
The cache flags used by your bot, the provided cache flags must all be present in JDA.getCacheFlags.
The intents used by your bot, must be passed as the entire list of intents your bot will use, i.e., JDABuilder's create(Light/Default)
methods and similar for shard managers, do not use JDABuilder.enableIntents.
Functions
Creates a JDABuilder with caches inferred from intents.
Creates a JDABuilder with caches inferred from intents.
Creates a JDABuilder with recommended default settings.
Creates a JDABuilder with low memory profile settings.
Creates a JDABuilder with recommended default settings.
Creates a JDABuilder with low memory profile settings.