-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: add wildcard components #188
Merged
Snazzah
merged 7 commits into
Snazzah:master
from
sudojunior:feature/wildcard-components
Nov 25, 2021
Merged
feat: add wildcard components #188
Snazzah
merged 7 commits into
Snazzah:master
from
sudojunior:feature/wildcard-components
Nov 25, 2021
+34
−2
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
Snazzah
requested changes
Nov 23, 2021
I could have also added a predicate return on the register method, which would have ended up looking like... class MessageInteractionContext {
// ...
registerWildcardComponent(message_id: string, /* ... */) {
// ...
return () => this.unregisterWildcardComponent(message_id);
}
} It is already so far against the existing style of the library, but I figured it'd be useful - similar to how I handled it in the demo. const unref = this.registerWildcardComponent('0123456789', ctx => {
// check interaction
unref(); // remove after pre-conditions pass
// continue
}); |
@sudojunior Sounds good, would have to change the other functions to match. |
…nteractionContext * registerComponent * registerComponentFrom * registerWildcardComponent
* Unsure if this is what was meant by the review comment... (or if i've covered all aspects)
…MessageInteractionContext" This reverts commit b7a4169.
Snazzah
approved these changes
Nov 25, 2021
{msg}-*
)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
scope: components
This has something to do with components
semver: minor
PRs that contain new features and will be on the next minor release
type: enhancement
New feature or request
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 extends further from #145 by adding a listener for all components on a message as a wildcard - the component used can be determined by
ctx.custom_id
.Added
MessageInteractionContext#registerWildcardComponent(message_id, callback, expiration, onExpired)
MessageInteractionContext#unregisterWildcardComponent(message_id)
Wildcard components use the invoking message ID with an asterisk (
*
) to prevent possible conflicts with existing registered components.For context sake, this was implemented with eda121e (Gist Component) with a specific use for ephemeral components (and having it unregister itself immediately before invoking the callback).