Fixed interaction payload/data type

This commit is contained in:
2025-01-05 14:43:12 -06:00
parent 202255d4ff
commit 8943b5a06e
3 changed files with 18 additions and 13 deletions
+1 -1
View File
@@ -14,5 +14,5 @@ export { Message, type MessagePayload, ComponentStyle, ComponentType } from './t
export { Embed } from './types/embed';
export { Emoji } from './types/emoji';
// Other
export { createCommandHandler } from './types/handler';
export { createCommandHandler, type InteractionData, type InteractionCommpoentData, type InteractionCommandData, type InteractionHandlerFunction } from './types/handler';
export { ApplicationCommandType, ApplicationCommandOptionType as CommandOptionType } from './types/applicationCommand';
+6 -4
View File
@@ -1,3 +1,4 @@
import { exists } from "../utils";
import { ApplicationCommandContext, ApplicationCommandOptionType, type ApplicationCommandOption } from "./applicationCommand";
import { Trait, type EventPayload } from "./common";
import type { Context } from "./context";
@@ -160,10 +161,11 @@ export function createCommandHandler<T extends readonly ApplicationCommandOption
return new CommandHandler(handler);
}
export type CommandHandlerFunction = (context: Context, args: any[]) => Promise<void> | void;
export type EventHandlerFunction = (context: Context | null, payload: EventPayload) => Promise<void> | void;
export type CommandHandlerFunction = (context: Context, args: any[]) => Promise<any> | any;
export type EventHandlerFunction = (context: Context | null, payload: EventPayload) => Promise<any> | any;
export type InteractionHandlerFunction<P = InteractionData> = (context: Context, payload: P) => Promise<any> | any;
export type HandlerWithoutContext = EventHandlerFunction;
export type HanderWithContext = CommandHandlerFunction | CommandHandler<readonly ApplicationCommandOption[]>;
export type HanderWithContext = InteractionHandlerFunction | CommandHandlerFunction | CommandHandler<readonly ApplicationCommandOption[]>;
export type Handler = EventHandlerFunction | CommandHandlerFunction | CommandHandler<readonly ApplicationCommandOption[]>;
export type Handler = InteractionHandlerFunction<InteractionCommpoentData> | InteractionHandlerFunction<InteractionCommandData> | EventHandlerFunction | CommandHandlerFunction | CommandHandler<readonly ApplicationCommandOption[]>;