diff --git a/src/components/componentcommand.ts b/src/components/componentcommand.ts index be2989b..55408da 100644 --- a/src/components/componentcommand.ts +++ b/src/components/componentcommand.ts @@ -14,13 +14,18 @@ export interface ComponentCommand { export abstract class ComponentCommand { type = InteractionCommandType.COMPONENT; abstract componentType: keyof ContextComponentCommandInteractionMap; - customId?: string; + customId?: string | RegExp; filter?(context: ComponentContext): Promise | boolean; abstract run(context: ComponentContext): any; /** @internal */ _filter(context: ComponentContext) { - if (this.customId && this.customId !== context.customId) return false; + if (this.customId) { + const isString = typeof this.customId === 'string'; + const matches = isString ? this.customId === context.customId : (this.customId as RegExp).test(context.customId); + + if (!matches) return false; + } if (this.filter) return this.filter(context); return true; }