fix: collect.run types

This commit is contained in:
MARCROCK22 2024-03-27 22:07:39 -04:00
parent 865f863e53
commit 4c05c25a41
3 changed files with 15 additions and 8 deletions

View File

@ -7,11 +7,9 @@ import type { Button } from './Button';
import type { TextInput } from './Modal';
import type { BuilderSelectMenus } from './SelectMenu';
export type ComponentCallback = (
interaction: ComponentInteraction | StringSelectMenuInteraction,
stop: ComponentStopCallback,
refresh: ComponentRefreshCallback,
) => any;
export type ComponentCallback<
T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction,
> = (interaction: T, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
export type ComponentFilterCallback<T = ComponentInteraction> = (interaction: T) => any;
export type ComponentStopCallback = (reason?: string, refresh?: ComponentRefreshCallback) => any;
export type ComponentRefreshCallback = () => any;

View File

@ -1,4 +1,4 @@
import type { GatewayVoiceState } from '../../common';
import type { GatewayVoiceState } from 'discord-api-types/v10';
import { GuildBasedResource } from './default/guild-based';
export class VoiceStates extends GuildBasedResource<VoiceStateResource> {

View File

@ -2,7 +2,7 @@ import type { ComponentCallback, ListenerOptions, ModalSubmitCallback } from '..
import { LimitedCollection } from '../collection';
import type { UsingClient } from '../commands';
import { BaseHandler, magicImport, type Logger, type OnFailCallback } from '../common';
import type { ComponentInteraction, ModalSubmitInteraction } from '../structures';
import type { ComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from '../structures';
import { ComponentCommand, InteractionCommandType, ModalCommand } from './command';
import { ComponentContext } from './componentcontext';
@ -54,7 +54,15 @@ export class ComponentHandler extends BaseHandler {
super(logger);
}
createComponentCollector(messageId: string, options: ListenerOptions = {}) {
createComponentCollector(
messageId: string,
options: ListenerOptions = {},
): {
run<
T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction,
>(customId: string | string[] | RegExp, callback: ComponentCallback<T>): any;
stop(reason?: string): any;
} {
this.values.set(messageId, {
components: [],
options,
@ -85,6 +93,7 @@ export class ComponentHandler extends BaseHandler {
});
return {
//@ts-expect-error generic
run: this.values.get(messageId)!.__run,
stop: (reason?: string) => {
this.deleteValue(messageId);