v3.0.0-alpha.14 | Improved channel options, retrieve thread by ID and reentrant transactions
Overview
Improved channel resolver support, added retrieving threads by IDs and enabled support for reentrant transactions
Add support for archived threads in text commands and components, improved resolution of slash command channel options (#164)
Added a few extensions to retrieve a thread by id, even if it is archived, as well as some improvements in built-in channel resolvers.
New features
- Added
Guild#retrieveThreadChannelOrNull
- Added
Guild#retrieveThreadChannelById
- Throws
InvalidChannelTypeException
if the channel ID does not represent a thread
- Throws
- Channel options now support (archived) threads in text commands and component data
- They will be retrieved if they are archived
- Added localization key
resolver.channel.missing_access.message
in case the thread channel exists but isn't accessible
- Channel options now support attribute channel types
- The channel types will be set to all channels which have the said attribute, unless overridden with
@ChannelTypes
. (For example, if you ask for aIPostContainer
, the option will acceptsForumChannel
s andMediaChannel
s)
- The channel types will be set to all channels which have the said attribute, unless overridden with
Removals
- [Small breaking] Removed
IThreadContainer#retrieveThreadChannelByIdOrNull
- Replaced with
Guild#retrieveThreadChannelOrNull
- Replaced with
- [Small breaking] Replaced
SlashCommandOption(Builder)#channelTypes
by@ChannelTypes
Add contextual data to parameter resolvers (#169)
Data is passed in some situations, allowing for some checks to be done.
New features
- Prevent usage of required guild-only entities in commands which can be used in DMs
Changes
- [Small breaking] Replaced
ParameterWrapper
in resolvers withResolverRequest
, holds theParameterWrapper
andRequestData
- Resolvers factories are now only checked if their output matches the requested resolver
- This does not break existing factories
- For example, a factory returning a
SlashParameterResolver
is only queried if it was requested for a slash command
Separate custom options and services, add annotations on component and timeout data (#171)
Annotations to differentiate what purpose a parameter is for, enables better exception messages and improve readability of your functions.
New features
- Added
serviceOption
to code-declared commands- Deprecated usages of
customOption
if the parameter is a service
- Deprecated usages of
- Added
@ComponentData
and@TimeoutData
- Add it on data passed in
bindTo
/timeout
- Logs a warning if annotation is not found
- Add it on data passed in
Changes
- Refresh method-injected
List
andLazyService
until they are stable (will not change later)- Still recommended to retrieve them from a constructor-injected
ServiceContainer
- Still recommended to retrieve them from a constructor-injected
New features
Components
- Added type-safe
timeout
function on persistent components, works the same as thebindTo
type-safe extensions
Database
- Added
DBResult#getKotlinInstant
- Added
DBResult#getKotlinInstantOrNull
- Added contracts to inline database functions
- Added support for reentrant transactions (commit)
- If you start a new transaction inside one, it will no longer deadlock, as it reuses the existing transaction
- NOTE: Reentrant connections requires a compatible read-only status
- You can always create a Read-only transaction only, but you cannot create a read-write transaction in a read-only one
- I highly recommend to return results early if possible, to avoid nesting and indentations
- If you want to do transactions in multiple steps, you can use "savepoints" manually
- [Small breaking] transaction block no longer support non-local returns
- Added suspending methods for
execute(Large)Batch
Built-in resolvers
- Added timeout parameter support for
Boolean
,Double
,Emoji
,Int
, andLong
, seeParameterResolver
- Added timeout parameter support in
enumResolver
Misc
- Added
User
/Member#asInputUser
- Added extensions to get an
InputUser
fromInteraction
,Message
andMessageReceivedEvent
: - Added several
RestAction
extensions: - Overriden "effective" getters in
InputUser
, so they always get the best value from theMember
, if available
Changes
Spring IoC
BContext
will start loading onceApplicationReadyEvent
is fired- This enables JDA to start when your application is ready
- Added
@Bean
to secondary service annotations (@Command
,@Resolver
...)
Dependency injection
- Using an explicit name on a
List
is an error - Deprecated
Lazy
, replaced withLazyService
- Does not allow for nullable types, use
ServiceContainer
to get them on-demand
- Does not allow for nullable types, use
Components
- [Small breaking] replaced
ModalInteractionEvent
withModalEvent
- Moved expiration timestamps to the base component entity
- If you don't use a database migration tool, you will need to run this script
Dependencies
- Kotlin: 1.9.23 -> 2.0.0-RC2
- JDA: 5.0.0-beta.22 -> 5.0.0-beta.24
- Bucket4J: 8.4.0 -> 8.12.0
- Artifact:
bucket4j-core
->bucket4j_jdk17-core
- Artifact:
- Jackson Databind: 2.16.1 -> 2.17.1
Fixes
Components
- Made
awaitOrNull
on components return the correct event type (#166) - Await on a component inside a group now throws an exception (#166)
- Groups of ephemeral components deleted on startup are now also deleted
- Select menu event type is now checked
Built-in resolvers
- Fixed
Resolvers#toHumanName
not replacing underscores
Spring IoC
- Added workaround to get bean types if unavailable (#165)
Dependency injection
- Fixed lazy services only being retrieved by their parameter name
- It now uses the parameter name, or fallbacks on matching the type
Don't hesitate to check out the changelogs and the wiki.
Full Changelog: v3.0.0-alpha.13...v3.0.0-alpha.14