diff --git a/src/structures/Message.js b/src/structures/Message.js index 11b6e282f..087ceaeff 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -817,6 +817,15 @@ class Message extends Base { return this.edit({ attachments: [] }); } + /** + * Resolves a component by a custom id. + * @param {string} customId The custom id to resolve against + * @returns {?MessageActionRowComponent} + */ + resolveComponent(customId) { + return this.components.flatMap(row => row.components).find(component => component.customId === customId) ?? null; + } + /** * Used mainly internally. Whether two messages are identical in properties. If you want to compare messages * without checking all the properties, use `message.id === message2.id`, which is much more efficient. This diff --git a/typings/index.d.ts b/typings/index.d.ts index cc5e1fd79..d258ca75c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1169,6 +1169,7 @@ export class Message extends Base { public react(emoji: EmojiIdentifierResolvable): Promise; public removeAttachments(): Promise; public reply(options: string | MessagePayload | ReplyMessageOptions): Promise; + public resolveComponent(customId: string): MessageActionRowComponent | null; public startThread(options: StartThreadOptions): Promise; public suppressEmbeds(suppress?: boolean): Promise; public toJSON(): unknown;