mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
docs
This commit is contained in:
@@ -61,7 +61,7 @@ import { Awaitable, SernEventsMapping, UnpackedDependencies, Dictionary } from '
|
|||||||
*
|
*
|
||||||
* @see {@link CommandControlPlugin} for plugin implementation
|
* @see {@link CommandControlPlugin} for plugin implementation
|
||||||
* @see {@link CommandType} for available command types
|
* @see {@link CommandType} for available command types
|
||||||
* @see {@link Dependencies} for dependency injection interface
|
* @see {@link Dependencies} for [dependency injection](https://sern.dev/v4/reference/dependencies/) interface
|
||||||
*/
|
*/
|
||||||
export type SDT = {
|
export type SDT = {
|
||||||
/**
|
/**
|
||||||
@@ -114,6 +114,10 @@ export type SDT = {
|
|||||||
|
|
||||||
export type Processed<T> = T & { name: string; description: string };
|
export type Processed<T> = T & { name: string; description: string };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface Module {
|
export interface Module {
|
||||||
type: CommandType | EventType;
|
type: CommandType | EventType;
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -196,13 +200,18 @@ export interface Module {
|
|||||||
execute(...args: any[]): Awaitable<any>;
|
execute(...args: any[]): Awaitable<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface SernEventCommand<T extends keyof SernEventsMapping = keyof SernEventsMapping>
|
export interface SernEventCommand<T extends keyof SernEventsMapping = keyof SernEventsMapping>
|
||||||
extends Module {
|
extends Module {
|
||||||
name?: T;
|
name?: T;
|
||||||
type: EventType.Sern;
|
type: EventType.Sern;
|
||||||
execute(...args: SernEventsMapping[T]): Awaitable<unknown>;
|
execute(...args: SernEventsMapping[T]): Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ExternalEventCommand extends Module {
|
export interface ExternalEventCommand extends Module {
|
||||||
name?: string;
|
name?: string;
|
||||||
emitter: keyof Dependencies;
|
emitter: keyof Dependencies;
|
||||||
@@ -210,83 +219,121 @@ export interface ExternalEventCommand extends Module {
|
|||||||
execute(...args: unknown[]): Awaitable<unknown>;
|
execute(...args: unknown[]): Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ContextMenuUser extends Module {
|
export interface ContextMenuUser extends Module {
|
||||||
type: CommandType.CtxUser;
|
type: CommandType.CtxUser;
|
||||||
execute: (ctx: UserContextMenuCommandInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: UserContextMenuCommandInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ContextMenuMsg extends Module {
|
export interface ContextMenuMsg extends Module {
|
||||||
type: CommandType.CtxMsg;
|
type: CommandType.CtxMsg;
|
||||||
execute: (ctx: MessageContextMenuCommandInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: MessageContextMenuCommandInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ButtonCommand extends Module {
|
export interface ButtonCommand extends Module {
|
||||||
type: CommandType.Button;
|
type: CommandType.Button;
|
||||||
execute: (ctx: ButtonInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: ButtonInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface StringSelectCommand extends Module {
|
export interface StringSelectCommand extends Module {
|
||||||
type: CommandType.StringSelect;
|
type: CommandType.StringSelect;
|
||||||
execute: (ctx: StringSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: StringSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ChannelSelectCommand extends Module {
|
export interface ChannelSelectCommand extends Module {
|
||||||
type: CommandType.ChannelSelect;
|
type: CommandType.ChannelSelect;
|
||||||
execute: (ctx: ChannelSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: ChannelSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface RoleSelectCommand extends Module {
|
export interface RoleSelectCommand extends Module {
|
||||||
type: CommandType.RoleSelect;
|
type: CommandType.RoleSelect;
|
||||||
execute: (ctx: RoleSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: RoleSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface MentionableSelectCommand extends Module {
|
export interface MentionableSelectCommand extends Module {
|
||||||
type: CommandType.MentionableSelect;
|
type: CommandType.MentionableSelect;
|
||||||
execute: (ctx: MentionableSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: MentionableSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface UserSelectCommand extends Module {
|
export interface UserSelectCommand extends Module {
|
||||||
type: CommandType.UserSelect;
|
type: CommandType.UserSelect;
|
||||||
execute: (ctx: UserSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: UserSelectMenuInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface ModalSubmitCommand extends Module {
|
export interface ModalSubmitCommand extends Module {
|
||||||
type: CommandType.Modal;
|
type: CommandType.Modal;
|
||||||
execute: (ctx: ModalSubmitInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: ModalSubmitInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface AutocompleteCommand {
|
export interface AutocompleteCommand {
|
||||||
onEvent?: ControlPlugin[];
|
onEvent?: ControlPlugin[];
|
||||||
execute: (ctx: AutocompleteInteraction, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: AutocompleteInteraction, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export interface DiscordEventCommand<T extends keyof ClientEvents = keyof ClientEvents>
|
export interface DiscordEventCommand<T extends keyof ClientEvents = keyof ClientEvents>
|
||||||
extends Module {
|
extends Module {
|
||||||
name?: T;
|
name?: T;
|
||||||
type: EventType.Discord;
|
type: EventType.Discord;
|
||||||
execute(...args: ClientEvents[T]): Awaitable<unknown>;
|
execute(...args: ClientEvents[T]): Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
* @see @link {commandModule} to create a text command
|
||||||
|
*/
|
||||||
export interface TextCommand extends Module {
|
export interface TextCommand extends Module {
|
||||||
type: CommandType.Text;
|
type: CommandType.Text;
|
||||||
execute: (ctx: Context & { get options(): string[] }, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: Context & { get options(): string[] }, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
* @see @link {commandModule} to create a slash command
|
||||||
|
*/
|
||||||
export interface SlashCommand extends Module {
|
export interface SlashCommand extends Module {
|
||||||
type: CommandType.Slash;
|
type: CommandType.Slash;
|
||||||
description: string;
|
description: string;
|
||||||
options?: SernOptionsData[];
|
options?: SernOptionsData[];
|
||||||
execute: (ctx: Context & { get options(): ChatInputCommandInteraction['options']}, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: Context & { get options(): ChatInputCommandInteraction['options']}, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
* @see @link {commandModule} to create a both command
|
||||||
|
*/
|
||||||
export interface BothCommand extends Module {
|
export interface BothCommand extends Module {
|
||||||
type: CommandType.Both;
|
type: CommandType.Both;
|
||||||
description: string;
|
description: string;
|
||||||
options?: SernOptionsData[];
|
options?: SernOptionsData[];
|
||||||
execute: (ctx: Context, tbd: SDT) => Awaitable<unknown>;
|
execute: (ctx: Context, tbd: SDT) => Awaitable<unknown>;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export type EventModule = DiscordEventCommand | SernEventCommand | ExternalEventCommand;
|
export type EventModule = DiscordEventCommand | SernEventCommand | ExternalEventCommand;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
export type CommandModule =
|
export type CommandModule =
|
||||||
| TextCommand
|
| TextCommand
|
||||||
| SlashCommand
|
| SlashCommand
|
||||||
@@ -355,6 +402,7 @@ export type InputCommand = {
|
|||||||
}[CommandType];
|
}[CommandType];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see @link {https://sern.dev/v4/reference/autocomplete/}
|
||||||
* Type that replaces autocomplete with {@link SernAutocompleteData}
|
* Type that replaces autocomplete with {@link SernAutocompleteData}
|
||||||
*/
|
*/
|
||||||
export type SernOptionsData =
|
export type SernOptionsData =
|
||||||
@@ -374,7 +422,9 @@ export interface SernSubCommandGroupData extends BaseApplicationCommandOptionsDa
|
|||||||
options?: SernSubCommandData[];
|
options?: SernSubCommandData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.0.0
|
||||||
|
*/
|
||||||
export interface ScheduledTaskContext {
|
export interface ScheduledTaskContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,7 +448,9 @@ interface TaskAttrs {
|
|||||||
*/
|
*/
|
||||||
deps: UnpackedDependencies
|
deps: UnpackedDependencies
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 4.0.0
|
||||||
|
*/
|
||||||
export interface ScheduledTask {
|
export interface ScheduledTask {
|
||||||
name?: string;
|
name?: string;
|
||||||
trigger: string | Date;
|
trigger: string | Date;
|
||||||
|
|||||||
Reference in New Issue
Block a user