Skip to content

v3.0.0-alpha.14 | Improved channel options, retrieve thread by ID and reentrant transactions

Compare
Choose a tag to compare
@freya022 freya022 released this 19 May 14:02
· 309 commits to 3.X since this release
7e6e62d

JDA version

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
  • 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 a IPostContainer, the option will accepts ForumChannels and MediaChannels)

Removals

  • [Small breaking] Removed IThreadContainer#retrieveThreadChannelByIdOrNull
  • [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 with ResolverRequest, holds the ParameterWrapper and RequestData
  • 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
  • Added @ComponentData and @TimeoutData
    • Add it on data passed in bindTo/timeout
    • Logs a warning if annotation is not found

Changes

  • Refresh method-injected List and LazyService until they are stable (will not change later)
    • Still recommended to retrieve them from a constructor-injected ServiceContainer

New features

Components

  • Added type-safe timeout function on persistent components, works the same as the bindTo 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, and Long, see ParameterResolver
  • Added timeout parameter support in enumResolver

Misc

Changes

Spring IoC

  • BContext will start loading once ApplicationReadyEvent 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 with LazyService

Components

  • [Small breaking] replaced ModalInteractionEvent with ModalEvent
  • 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
  • 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

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