diff --git a/src/builders/types.ts b/src/builders/types.ts index 93606d3..5e462ec 100644 --- a/src/builders/types.ts +++ b/src/builders/types.ts @@ -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 = (interaction: T) => any; export type ComponentStopCallback = (reason?: string, refresh?: ComponentRefreshCallback) => any; export type ComponentRefreshCallback = () => any; diff --git a/src/cache/resources/voice-states.ts b/src/cache/resources/voice-states.ts index 50933f4..92d868b 100644 --- a/src/cache/resources/voice-states.ts +++ b/src/cache/resources/voice-states.ts @@ -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 { diff --git a/src/components/handler.ts b/src/components/handler.ts index c2bc564..b92b9bb 100644 --- a/src/components/handler.ts +++ b/src/components/handler.ts @@ -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): 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);