@jadl/cmd
Version:
A command handler for JADL
33 lines (32 loc) • 1.55 kB
TypeScript
import { Worker } from 'jadl';
import { CommandFactory } from '../handler/CommandFactory';
import { GatewayInteractionCreateDispatchData, Snowflake } from 'discord-api-types/v9';
import { CommandInteraction } from '../types';
import { MessageTypes } from '@jadl/builders';
import { APIInteraction, RESTPostAPIInteractionCallbackJSONBody } from 'discord-api-types/v10';
import { InteractionCommandResponse } from '../structures/InteractionCommandResponse';
import { WorkerInject } from '../structures/WorkerInject';
export declare type MessageReturnType = MessageTypes | InteractionCommandResponse;
export interface CommandHandlerOptions {
/**
* Guild to post all commands to (useful for testing)
*/
interactionGuild?: Snowflake;
/**
* Whether or not to make errors ephemeral
* @default true
*/
ephemeralError?: boolean;
}
export declare class CommandHandler extends CommandFactory {
readonly worker: Worker;
options: CommandHandlerOptions;
constructor(worker: Worker, injections: Array<WorkerInject | (new () => any)>, options?: CommandHandlerOptions);
private formCommandEndpoint;
updateInteractions(): Promise<void>;
handleInteraction(_interaction: GatewayInteractionCreateDispatchData): Promise<void>;
private editOriginal;
static callback(worker: Worker, body: RESTPostAPIInteractionCallbackJSONBody, int: APIInteraction): Promise<unknown>;
private callback;
handleRes(res: MessageReturnType, int: CommandInteraction): Promise<void>;
}