What's new in v3.2
Maintenance mode for v3.1
After v3.2.0 releases, only bugfixes will be accepted in the 3.1.x branch.
Features
New entity cache abstraction: Store
While developing v3.1.x some limitations were encountered if trying to implement a custom entity cache pursuing efficiency, as a given abstraction to organize data was fixed on implementations ("9-Store layout"), that forced cache operations around a generic find/save set of operations, without taking into consideration the relational aspect some entities have and could be leveraged for improved performance.
To address this and other problems, an abstraction named Store is introduced in #788
around a command-oriented pattern by requiring a single method: execute(StoreAction). This method is responsible for
receiving both Gateway updates and user-facing queries, giving implementations no restrictions, but tools that help with the process.
Some of the most notable components added:
StoreLayout: the minimal set of methods that are required to support a Discord cache: Gateway updates, and data-access queriesActionMapper: a registry forStoreActioninstances passed to theStoreReadActions: all queries placed in a convenient class, to build actionsDispatchStoreLayer: introduce caching capabilities to users operating exclusively with thegatewaymodule
Regarding project organization, Store now lives in the discord4j-common module, dropping the dependency on stores-api.
This also means structures like StateHolder and StateView are no longer present. Check the migration guide for details.
New immutable spec API
After receiving feedback regarding Consumer-based request builders, a new set of APIs were introduced in #927,
aiming to help with API request building. Multiple patterns are available so please check the Specs page for more information.
Preparing for threads
In order to easily migrate to a new channel hierarchy supporting threads, some changes were applied to v3.2 deprecating methods that won't be available in v3.3 after thread channels are implemented in #923.
API changes
Signature changes
- Slash command methods that previously took
WebhookMultipartRequestnow takeMultipartRequest<WebhookExecuteRequest>and can be built using one of its static factory methods - Optional returns from Message.Embed methods (previously returning
null) #749 - GatewayResources::getIntents return type changes from
Possible<IntentSet>toIntentSet - RestGuild::modifyMember and GuildService::modifyGuildMember return type changes from
Mono<Void>toMono<MemberData> - Message::getAttachments return type changes from
Set<Attachment>toList<Attachment> - DiscordWebClient supports a custom baseUrl #902
- ChannelService::editMessage 3rd parameter changes from
MessageEditRequesttoMultipartRequest<MessageEditRequest>- If you used this method before, you can wrap the old request using
MultipartRequest.ofRequest(request)
- If you used this method before, you can wrap the old request using
Updates due to new Reactor API
- GatewayClient::close return type changes from
Mono<Void>toMono<CloseStatus> - GatewayClient::sender return type changes from
FluxSink<GatewayPayload<?>>toSinks.Many<GatewayPayload<?>>
Changes around Message mentions #858
- Message::getUserMentionIds return type changes from
Set<Snowflake>toList<Snowflake> - Message::getUserMentions return type changes from
Flux<User>toList<User> - Message::getRoleMentionIds return type changes from
Set<Snowflake>toList<Snowflake> - Message::getReactions return type changes from
Set<Reaction>toList<Reaction>
Changes around UserData direct usage #898
- PrivateChannel::getRecipients return type changes from
Flux<User>toSet<User> - Invite::getInviter return type changes from
Mono<User>toOptional<User> - Inviter::getTargetUser return type changes from
Mono<User>toOptional<User>
Data type changes from Discord
- Member::getJoinTime return type changes from
InstanttoOptional<Instant> - MemberUpdateEvent::getJoinTime return type changes from
InstanttoOptional<Instant>
Audit log changes #899
- ChangeKey.ROLES_ADD and ChangeKey.ROLES_REMOVE type change from
ChangeKey<Set<Role>>toChangeKey<Set<AuditLogRole>>to properly reflect the data type returned from Discord. Containsidandname. - OptionKey.DELETE_MEMBER_DAYS and OptionKey.MEMBERS_REMOVED type change from
OptionKey<String>toOptionKey<Integer>
New types
- Store, StoreLayout and others related to the Store rework #788
- ClientPresence and ClientActivity to be used when setting the bot's status #874
Moved and renamed types
- Due to immutable specs #927, Consumer-based
XXSpecclasses are now located atdiscord4j.core.spec.legacypackage and renamed toLegacyXXSpec. They are deprecated to encourage usage of the new patterns, and might be removed in a future release
Removed types
- PrivateChannelCreateEvent
- StateView
- InvalidationStrategy
Deprecations
Multiple embeds in a message #950
MessageCreateSpec::setEmbedandMessageEditSpec::setEmbed- Use new specs or
addEmbed(Consumer)orremoveEmbeds()
Prepare new channel hierarchy for threads #959
GuildChannelmethods moving toTopLevelGuildChannelgetPermissionOverwritesgetOverwriteForMembergetOverwriteForRolegetRawPositiongetPositionaddMemberOverwriteaddRoleOverwrite
GuildMessageChannelmethods moving toTopLevelGuildMessageChannelgetTopiccreateWebhookgetWebhooks
GuildMessageChannelshould no longer be treated as a subtype ofCategorizableChannel. These methods are deprecated "for removal"getCategoryIdgetCategorycreateInvitegetInvites
Additions
- IntentSet.nonPrivileged() is the new default
- MemberUpdateEvent::getCurrentRoles returns a
Flux<Role>#807 - New API to get self member #871
- EntityRetriever.getSelfMember(guildId)
- RestClient.selfRestMember(guildId)
- RestClient.getSelfMember(guildId)
- Member-based permission calculation #873
- GuildChannel.getEffectivePermissions(Member)
- Audit log changes #899
- Guild::getAuditLog methods now return
Flux<AuditLogPart>to provide easier access to all related entities
- Guild::getAuditLog methods now return
Renames
- MemberUpdateEvent::getCurrentRoles renamed to MemberUpdateEvent::getCurrentRoleIds #807
Removals
- Guild ::getEmbedChannel / ::getEmbedChannelId (was deprecated in 3.1.x, use getWidget*)
- RestGuild ::getEmbed / ::modifyEmbed (was deprecated in 3.1.x, use getWidget & modifyWidget)
- Removals due to new Store API, see migration notes
- GatewayResources::getStateView (replaced with ::getStore)
- GatewayBootstrap::setStoreService (replaced with ::setStore)
- GatewayBootstrap::setInvalidationStrategy (look for
StorageConfigbuilder for a replacement)
- RestGuild::getIntegrations(boolean) and GuildService::getGuildIntegrations(long, boolean) #803
- Message::getUserMentions(EntityRetrievalStrategy) (no fetching strategy needed) #858
- UserService::getUserDMs (deprecated endpoint) #890
- Use provided data over cached one where possible #898
- Invite::getInviter(EntityRetrievalStrategy) (no fetching strategy needed)
- Invite::getTargetUser(EntityRetrievalStrategy) (no fetching strategy needed)
- PrivateChannel::getRecipients(EntityRetrievalStrategy) (no fetching strategy needed)
Behavior changes
- As part of v8 and above changes, Intents are mandatory so the new default if you don't set any will be IntentSet.nonPrivileged()
- Default to MemberRequestFilter.none if missing GUILD_MEMBERS intent
- RestGuild::getData now includes with_counts = true by default #826