mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
refactor: update customId matching logic and rename asyncRun to waitFor
This commit is contained in:
parent
b84d462ce2
commit
e810b6eb52
@ -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);
|
||||
|
@ -38,7 +38,7 @@ export interface CreateComponentCollectorResult {
|
||||
callback: ComponentCallback<T>,
|
||||
): void;
|
||||
stop(reason?: string): void;
|
||||
asyncRun<T extends CollectorInteraction = CollectorInteraction>(customId: UserMatches): Promise<T | null>;
|
||||
waitFor<T extends CollectorInteraction = CollectorInteraction>(customId: UserMatches): Promise<T | null>;
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user