Repository navigation
Added ComponentIdInteractor delegate - #588
Merged
Zabuzard merged 6 commits intoOct 13, 2022
Merged
Conversation
Member
Author
|
(FYI @SquidXTV ) |
Tais993
reviewed
Sep 29, 2022
Zabuzard
force-pushed
the
feature/simplify_user_interactor_without_adapter
branch
from
September 30, 2022 13:16
d6050af to
f9fa20d
Compare
Zabuzard
force-pushed
the
feature/simplify_user_interactor_without_adapter
branch
from
October 4, 2022 10:20
f9fa20d to
de388e7
Compare
Tais993
reviewed
Oct 4, 2022
Tais993
left a comment
Member
There was a problem hiding this comment.
The issue with the prefix enum before was that the component ID generation needed the prefixed name.
But that still is the case, so what have you actually changed?
Zabuzard
force-pushed
the
feature/simplify_user_interactor_without_adapter
branch
from
October 8, 2022 19:19
ae179f9 to
0f0832c
Compare
|
Kudos, SonarCloud Quality Gate passed! |
Merged
This file contains hidden or 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
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.








Overview
This adds a new class called
ComponentIdInteractor, which effectively is a delegate-pattern solution to provide component-ID generation based out of a class that can be used as delegate for composition, instead of relying on the existingBotCommandAdapterinheritance.Essentially, the existing code to generate component IDs has been moved out of
BotCommandAdapterinto this class instead.BotCommandAdapternow delegates toComponentIdInteractorfor this functionality.Advantage
The benefit is that non-
BotCommandclasses, in particularRoutines can now easily access this functionality as well. For example, a routine might now easily create buttons like this:Redesign prefix
While at it, the whole topic with
UserInteractorPrefixwas redesigned. It is now essentially renamed toUserInteractionTypeand will not only be used for prefixes, but essentailly just represents the type of interaction.This is then used by
BotCorefor prefix-based-forwarding. Implementations ofUserInteractornow have to explicitly tell their type instead of the system being based on the classes and reflection.This gives maximum flexibility. At the same time, it is still convenient though, since everything is hidden behind the adapters for 99% of the use cases.
BotCommandAdapternow auto-infers the type based on the JDA command types, for the commands its responsible for (slash, user context, message context).Checklist
ScamBlockeruse the delegate