-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add way to intercept events and insert custom context #667
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # core/src/main/kotlin/gateway/handler/ChannelEventHandler.kt # core/src/main/kotlin/gateway/handler/GuildEventHandler.kt # core/src/main/kotlin/gateway/handler/InteractionEventHandler.kt # core/src/main/kotlin/gateway/handler/LifeCycleEventHandler.kt # core/src/main/kotlin/gateway/handler/MessageEventHandler.kt # core/src/main/kotlin/gateway/handler/ThreadEventHandler.kt # core/src/main/kotlin/gateway/handler/VoiceEventHandler.kt # core/src/main/kotlin/gateway/handler/WebhookEventHandler.kt
|
lukellmann
force-pushed
the
0.8.x
branch
2 times, most recently
from
August 17, 2022 12:47
a1bb076
to
1e6718a
Compare
# Conflicts: # core/src/main/kotlin/event/channel/ChannelCreateEvent.kt # core/src/main/kotlin/event/channel/ChannelDeleteEvent.kt # core/src/main/kotlin/event/channel/ChannelUpdateEvent.kt # core/src/main/kotlin/event/channel/thread/ThreadCreateEvent.kt # core/src/main/kotlin/event/channel/thread/ThreadDeleteEvent.kt # core/src/main/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt # core/src/main/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt # core/src/main/kotlin/event/channel/thread/ThreadUpdateEvent.kt # core/src/main/kotlin/event/gateway/Events.kt # core/src/main/kotlin/event/guild/GuildCreateEvent.kt # core/src/main/kotlin/event/guild/GuildDeleteEvent.kt # core/src/main/kotlin/event/guild/GuildUpdateEvent.kt # core/src/main/kotlin/event/guild/MemberLeaveEvent.kt # core/src/main/kotlin/event/interaction/ApplicationCommandCreate.kt # core/src/main/kotlin/event/interaction/ApplicationCommandDelete.kt # core/src/main/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt # core/src/main/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt # core/src/main/kotlin/event/interaction/ApplicationCommandUpdate.kt # core/src/main/kotlin/event/interaction/AutoCompleteInteractionCreate.kt # core/src/main/kotlin/event/interaction/ComponentInteractionCreate.kt # core/src/main/kotlin/event/interaction/ModalSubmitInteractionCreate.kt # core/src/main/kotlin/event/user/UserUpdateEvent.kt # core/src/main/kotlin/event/user/VoiceStateUpdateEvent.kt # core/src/main/kotlin/gateway/handler/BaseGatewayEventHandler.kt # core/src/main/kotlin/gateway/handler/ChannelEventHandler.kt # core/src/main/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt # core/src/main/kotlin/gateway/handler/GuildEventHandler.kt # core/src/main/kotlin/gateway/handler/InteractionEventHandler.kt # core/src/main/kotlin/gateway/handler/LifeCycleEventHandler.kt # core/src/main/kotlin/gateway/handler/MessageEventHandler.kt # core/src/main/kotlin/gateway/handler/ThreadEventHandler.kt # core/src/main/kotlin/gateway/handler/UserEventHandler.kt # core/src/main/kotlin/gateway/handler/VoiceEventHandler.kt # core/src/main/kotlin/gateway/handler/WebhookEventHandler.kt
The changeset is too large for me to review by hand, but the functionality as presented by this PR description looks fine and should be plenty sufficient for KordEx. |
The most important changes are in the following files:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adresses #665 (comment) by adding a way to insert a custom object into events.
The way to do this is by overwriting
GatewayEventInterceptor
for aKord
instance. The interceptor can then assign acustomContext
when creating core events. The interceptor can be changed viagatewayEventInterceptor
inKordBuilder
. For convenience,DefaultGatewayEventInterceptor
can be created with a lambda that creates the object that will be assigned tocustomContext
.Code example:
Note that the reference to
customContext
will be copied bywithStrategy()
ofStrategizable
events.See this conversation (especially this message) for the decision to use
Any?
forcustomContext
.This PR also fixes
withStrategy()
forTypingStartEvent
,ThreadListSyncEvent
,InviteCreateEvent
andReactionRemoveEmojiEvent
.