v3.0.0-alpha.23 | Improved dynamic DI, simplified runtime filters, and general improvements
Overview
Improved built-in DI capabilities, simplified runtime filters, and general usability improvements.
Replaced DynamicSupplier with user-defined service suppliers (#225, #226)
This aims to allow defining services earlier in the loading process, for example, when initializing the framework, or while discovering classes.
One use case is to define services when discovering an interface with a given annotation; a similar example in Spring would be JPA repositories (using @Repository on an interface that gets implemented automatically).
Breaking changes
- Removed
DynamicSupplier
Deprecations
- Deprecated instance suppliers
InstanceSupplierBServiceConfig#instanceSupplierMapBServiceConfigBuilder#registerInstanceSupplier
Changes
- Passed a
ServiceContainerinClassGraphProcessormethods - Annotations are no longer read from classes supplied by
InstanceSuppliers- This shouldn't affect anyone as you would use a service factory instead
New features
- Added
ServiceSupplier- This lets you configure a service with a bit more depth
- Added
DefaultServiceContainer#putSuppliedService(ServiceSupplier)- You should be able to call this from a
ClassGraphProcessor, for example, if you want to register proxied interfaces as services
- You should be able to call this from a
- Added
BServiceConfigBuilder#registerServiceSupplier(...)
Removed append attributes from @UserPermission, @BotPermissions and @Test (#227)
You will now have to annotate the affected function directly, to clarify what affects a function, however, to reduce repetition, you can use them as meta-annotations, combine them and override them.
Breaking changes
- Removed the
appendattribute - Removed the
CLASStarget - If
findAllAnnotationsencounters the target annotation, this will override meta-annotations (children annotations) ifdirectOverridesistrue findAllAnnotationshas no defined order anymore
Changes
- Added the
ANNOTATION_CLASStarget
Slightly simplified filters (#228)
A rejection handler is no longer mandatory, however, you can keep using it if you wish, by calling it yourself.
Breaking changes
- You no longer need to make rejection handlers
- Instead of returning arbitrary data, you handle the rejection in the filter directly, and return a string for logging purposes
- I recommend using a separate function/class to reduce maintenance
- The
globalproperty of filters is now abstract- Clarifies which filter is global or command-specific
Breaking changes
Built-in dependency injection
- Removed
ServiceContainer#lazyService- This already existed as
lazy
- This already existed as
Changes
Dependencies
- Kotlin: 2.0.0 -> 2.1.0
- kotlinx-coroutines: 1.9.2 -> 1.10.1
- (Optional) Spring boot: 3.2.12 -> 3.4.2
- kotlinx-datetime: 0.5.0 -> 0.6.1
- ClassGraph: 4.8.175 -> 4.8.179
- Caffeine: 3.1.8 -> 3.2.0
- slf4j-api: 2.0.13 -> 2.0.16
- kotlin-logging: 7.0.0 -> 7.0.3
- (Optional) HikariCP: 5.1.0 -> 6.2.1
App emojis
- Throw exception if not enough slots are available
New features
App emojis
- Added
BAppEmojisConfig#deleteOnOutOfSlots- If there are not enough slots, it will delete the oldest application emojis that aren't required by the bot
Localization
- Added
LocalizationContext#fromLocaleProviders- This helps you create a localization context using the same locales as using the events would
- This can be useful when replying in an interaction filter
- Adding a
/prefix to your template key will make the library ignore any set prefix- Example:
/my.command.responses.okwill stay asmy.command.responses.okeven if a prefix is set
- Example:
Components
- Added a few helpers to create
IdentifiableComponentfrom JDA components - Added a few helpers to remove stored components using JDA components
Misc
- Added a few utilities to convert from/to Kotlin/Java functions in
ReflectionUtils
Bug fixes
Built-in dependency injection
- Fixed using
LazyServicein Java constructors
App emojis
- Fixed app emojis being enabled by default on Spring apps
Don't hesitate to check out the examples and the wiki.
Full Changelog: v3.0.0-alpha.22...v3.0.0-alpha.23