mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(MessageComponentInteraction): component getter (#5840)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com> Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com>
This commit is contained in:
@@ -57,6 +57,19 @@ class MessageComponentInteraction extends Interaction {
|
||||
this.webhook = new InteractionWebhook(this.client, this.applicationID, this.token);
|
||||
}
|
||||
|
||||
/**
|
||||
* The component which was interacted with
|
||||
* @type {?(MessageActionRowComponent|Object)}
|
||||
* @readonly
|
||||
*/
|
||||
get component() {
|
||||
return (
|
||||
this.message.components
|
||||
.flatMap(row => row.components)
|
||||
.find(component => (component.customID ?? component.custom_id) === this.customID) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the type of a MessageComponent
|
||||
* @param {MessageComponentTypeResolvable} type The type to resolve
|
||||
|
||||
Reference in New Issue
Block a user