From e810b6eb5204398d738b398dcbdfd2357a96f1ef Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Sat, 14 Jun 2025 19:24:53 -0400 Subject: [PATCH] refactor: update customId matching logic and rename asyncRun to waitFor --- src/components/componentcommand.ts | 5 ++--- src/components/handler.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/componentcommand.ts b/src/components/componentcommand.ts index 55408da..73c4a7c 100644 --- a/src/components/componentcommand.ts +++ b/src/components/componentcommand.ts @@ -21,9 +21,8 @@ export abstract class ComponentCommand { /** @internal */ _filter(context: ComponentContext) { if (this.customId) { - const isString = typeof this.customId === 'string'; - const matches = isString ? this.customId === context.customId : (this.customId as RegExp).test(context.customId); - + const matches = + typeof this.customId === 'string' ? this.customId === context.customId : context.customId.match(this.customId); if (!matches) return false; } if (this.filter) return this.filter(context); diff --git a/src/components/handler.ts b/src/components/handler.ts index de370b7..8460e50 100644 --- a/src/components/handler.ts +++ b/src/components/handler.ts @@ -38,7 +38,7 @@ export interface CreateComponentCollectorResult { callback: ComponentCallback, ): void; stop(reason?: string): void; - asyncRun(customId: UserMatches): Promise; + waitFor(customId: UserMatches): Promise; resetTimeouts(): void; } @@ -117,7 +117,7 @@ export class ComponentHandler extends BaseHandler { this.createComponentCollector(messageId, channelId, guildId, options, old.components); }); }, - asyncRun: customId => + waitFor: customId => new Promise(resolve => { const collector = this.values.get(messageId); if (!collector) return resolve(null);