feat(Message): Add method to resolve a component by id #6484
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.
Please describe the changes this PR makes and why it should be merged:
Now that the API enforces custom ids to be unique in components in a message, I want to go ahead and propose this new method!
This will add the
<Message>.resolveComponent()
method. By supplying a custom id, the desired component will be returned (ornull
if not found). The use case for this is when the desired behaviour is altering the state of some other specific component upon the interaction of a component on the same message. For me, this is altering the.disabled
property of a button or a select menu.I understand I can simply index the components array like so:
<ButtonInteraction>.message.components[<number>].components[<number>]
. However, I don't think this is quite right. I am assuming that the component I want to edit will always be on a specific row on a specific column. Why should I do this when I have a custom id? Finding a component by a custom id seems like a more intuitive approach, hence why I have this method!Feel free to suggest/request changes!
Status and versioning classification: