@sern/handler
Version:
A complete, customizable, typesafe, & reactive framework for discord bots.
51 lines (50 loc) • 2.61 kB
TypeScript
import type { Module, SernAutocompleteData, SernOptionsData } from '../types/core-modules';
import type { AnySelectMenuInteraction, ButtonInteraction, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, ModalSubmitInteraction, UserContextMenuCommandInteraction, AutocompleteInteraction } from 'discord.js';
import { InteractionType } from 'discord.js';
import { PluginType } from './structures/enums';
import type { Payload, UnpackedDependencies } from '../types/utility';
export declare const createSDT: (module: Module, deps: UnpackedDependencies, params: string | undefined) => {
state: {};
deps: UnpackedDependencies;
params: string | undefined;
type: import("./structures/enums").CommandType | import("./structures/enums").EventType;
module: {
name: string | undefined;
description: string | undefined;
locals: import("../types/utility").Dictionary;
meta: {
id: string;
absPath: string;
};
};
};
/**
* Removes the first character(s) _[depending on prefix length]_ of the message
* @param msg
* @param prefix The prefix to remove
* @returns The message without the prefix
* @example
* message.content = '!ping';
* console.log(fmt(message.content, '!'));
* // [ 'ping' ]
*/
export declare function fmt(msg: string, prefix?: string): string[];
export declare function partitionPlugins<T, V>(arr?: Array<{
type: PluginType;
}>): [T[], V[]];
export declare const createLookupTable: (options: SernOptionsData[]) => Map<string, SernAutocompleteData>;
interface InteractionTypable {
type: InteractionType;
}
type AnyMessageComponentInteraction = AnySelectMenuInteraction | ButtonInteraction;
type AnyCommandInteraction = ChatInputCommandInteraction | MessageContextMenuCommandInteraction | UserContextMenuCommandInteraction;
export declare function isMessageComponent(i: InteractionTypable): i is AnyMessageComponentInteraction;
export declare function isCommand(i: InteractionTypable): i is AnyCommandInteraction;
export declare function isContextCommand(i: AnyCommandInteraction): i is MessageContextMenuCommandInteraction | UserContextMenuCommandInteraction;
export declare function isAutocomplete(i: InteractionTypable): i is AutocompleteInteraction;
export declare function isModal(i: InteractionTypable): i is ModalSubmitInteraction;
export declare function resultPayload<T extends 'success' | 'warning' | 'failure'>(type: T, module?: Module, reason?: unknown): Payload & {
type: T;
};
export declare function pipe<T>(arg: unknown, firstFn: Function, ...fns: Function[]): T;
export {};