Files
website/docs/api/modules.md
2023-01-12 22:06:31 -06:00

24 KiB

id, title, sidebar_label, sidebar_position, custom_edit_url
id title sidebar_label sidebar_position custom_edit_url
modules @sern/handler Exports 0.5 null

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

AnyCommandPlugin

Ƭ AnyCommandPlugin: ControlPlugin | InitPlugin<[InitArgs<Processed<CommandModule>>]>

Defined in

src/types/plugin.ts:38


AnyDefinedModule

Ƭ AnyDefinedModule: Processed<CommandModule | EventModule>

After modules are transformed, name and description are given default values if none are provided to Module. This type represents that transformation

Defined in

src/types/handler.ts:23


AnyEventPlugin

Ƭ AnyEventPlugin: ControlPlugin | InitPlugin<[InitArgs<Processed<EventModule>>]>

Defined in

src/types/plugin.ts:39


AnyModule

Ƭ AnyModule: CommandModule | EventModule

Defined in

src/types/module.ts:150


Args

Ƭ Args: ParseType<{ slash: SlashOptions ; text: string[] }>

Defined in

src/types/handler.ts:15


AutocompletePlugin

Ƭ AutocompletePlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:46


BaseOptions

Ƭ BaseOptions: ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData | ApplicationCommandNumericOptionData | ApplicationCommandAttachmentOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/types/module.ts:203


CommandArgs

Ƭ CommandArgs<I, J>: CommandArgsMatrix[I][J]

Type parameters

Name Type
I extends CommandType = CommandType
J extends PluginType = PluginType

Defined in

src/handler/plugins/args.ts:109


CommandModule

Ƭ CommandModule: TextCommand | SlashCommand | BothCommand | ContextMenuUser | ContextMenuMsg | ButtonCommand | StringSelectCommand | MentionableSelectCommand | UserSelectCommand | ChannelSelectCommand | RoleSelectCommand | ModalSubmitCommand

Defined in

src/types/module.ts:136


CommandModuleDefs

Ƭ CommandModuleDefs: Object

Type declaration

Name Type
1 TextCommand
1024 RoleSelectCommand
16 ButtonCommand
2 SlashCommand
2048 UserSelectCommand
256 ChannelSelectCommand
3 BothCommand
32 StringSelectCommand
4 ContextMenuUser
512 MentionableSelectCommand
64 ModalSubmitCommand
8 ContextMenuMsg

Defined in

src/types/module.ts:154


CommandModuleNoPlugins

Ƭ CommandModuleNoPlugins: { [T in CommandType]: Omit<CommandModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/types/module.ts:185


CommandPlugin

Ƭ CommandPlugin<T>: Deprecated<"Please use InitPlugin instead: ">

Type parameters

Name Type
T extends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/types/plugin.ts:41


Deprecated

Ƭ Deprecated<Message>: [never, Message]

Type parameters

Name Type
Message extends string

Defined in

src/types/handler.ts:64


DiscordEmitterPlugin

Ƭ DiscordEmitterPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:43


DiscordEventPlugin

Ƭ DiscordEventPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:50


EventArgs

Ƭ EventArgs<I, J>: EventArgsMatrix[I][J]

Type parameters

Name Type
I extends EventType = EventType
J extends PluginType = PluginType

Defined in

src/handler/plugins/args.ts:113


EventModule

Ƭ EventModule: DiscordEventCommand | SernEventCommand | ExternalEventCommand

Defined in

src/types/module.ts:135


EventModuleDefs

Ƭ EventModuleDefs: Object

Type declaration

Name Type
1 DiscordEventCommand
2 SernEventCommand
3 ExternalEventCommand

Defined in

src/types/module.ts:169


EventModulesNoPlugins

Ƭ EventModulesNoPlugins: { [T in EventType]: Omit<EventModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/types/module.ts:188


EventPlugin

Ƭ EventPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:47


ExternalEmitterPlugin

Ƭ ExternalEmitterPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:44


ExternalEventPlugin

Ƭ ExternalEventPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:49


InputCommand

Ƭ InputCommand: { [T in CommandType]: CommandModuleNoPlugins[T] & Object }[CommandType]

Defined in

src/types/module.ts:196


InputEvent

Ƭ InputEvent: { [T in EventType]: EventModulesNoPlugins[T] & Object }[EventType]

Defined in

src/types/module.ts:192


LogPayload

Ƭ LogPayload<T>: Object

Type parameters

Name Type
T unknown

Type declaration

Name Type
message T

Defined in

src/types/handler.ts:34


MapDeps

Ƭ MapDeps<Deps, T>: T extends [infer First, ...(infer Rest extends readonly unknown[])] ? [UnpackFunction<Deps[First]>, ...(MapDeps<Deps, Rest> extends [never] ? [] : MapDeps<Deps, Rest>)] : [never]

Type parameters

Name Type
Deps extends Dependencies
T extends readonly unknown[]

Defined in

src/types/handler.ts:52


OptionalDependencies

Ƭ OptionalDependencies: "@sern/logger"

Defined in

src/types/handler.ts:62


ParseType

Ƭ ParseType<T>: { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

Name
T

Defined in

src/types/handler.ts:11


Payload

Ƭ Payload: { module: AnyModule ; type: Success } | { module?: AnyModule ; reason: string | Error ; type: Failure } | { reason: string ; type: Warning }

Defined in

src/types/handler.ts:24


PluginResult

Ƭ PluginResult: Awaitable<VoidResult>

Defined in

src/types/plugin.ts:21


Processed

Ƭ Processed<T>: T & { description: string ; name: string }

Type parameters

Name Type
T extends Module

Defined in

src/types/handler.ts:63


ReplyOptions

Ƭ ReplyOptions: string | Omit<InteractionReplyOptions, "fetchReply"> | MessageReplyOptions

Defined in

src/types/handler.ts:47


SernEmitterPlugin

Ƭ SernEmitterPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:45


SernEventPlugin

Ƭ SernEventPlugin: Deprecated<"Please view alternatives: ">

Defined in

src/types/plugin.ts:48


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

Name Type
error [Payload]
module.activate [Payload]
module.register [Payload]
warning [Payload]

Defined in

src/types/handler.ts:28


SernOptionsData

Ƭ SernOptionsData<U>: U extends ApplicationCommandSubCommandData ? SernSubCommandData : U extends ApplicationCommandSubGroupData ? SernSubCommandGroupData : BaseOptions

Type parameters

Name Type
U extends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/types/module.ts:223


Singleton

Ƭ Singleton<T>: () => T

Type parameters

Name
T

Type declaration

▸ (): T

Returns

T

Defined in

src/types/handler.ts:35


SlashOptions

Ƭ SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">

Defined in

src/types/handler.ts:17


Transient

Ƭ Transient<T>: () => () => T

Type parameters

Name
T

Type declaration

▸ (): () => T

Returns

fn

▸ (): T

Returns

T

Defined in

src/types/handler.ts:36


VoidResult

Ƭ VoidResult: Result<void, void>

Defined in

src/types/plugin.ts:22

Variables

controller

Const controller: Object

The object passed into every plugin to control a command's behavior

Type declaration

Name Type
next () => OkImpl<void>
stop () => ErrImpl<void>

Defined in

src/handler/sern.ts:56

Functions

CommandControlPlugin

CommandControlPlugin<I>(execute): Plugin<unknown[]>

Type parameters

Name Type
I extends CommandType

Parameters

Name Type
execute (...args: CommandArgs<I, Control>) => PluginResult

Returns

Plugin<unknown[]>

Defined in

src/handler/plugins/createPlugin.ts:28


CommandInitPlugin

CommandInitPlugin<I>(execute): Plugin<unknown[]>

Type parameters

Name Type
I extends CommandType

Parameters

Name Type
execute (...args: CommandArgs<I, Init>) => PluginResult

Returns

Plugin<unknown[]>

Defined in

src/handler/plugins/createPlugin.ts:22


DiscordEventControlPlugin

DiscordEventControlPlugin<T>(name, execute): Plugin<unknown[]>

Experimental

A specialized function for creating control plugins with discord.js ClientEvents. Will probably be moved one day!

Type parameters

Name Type
T extends keyof ClientEvents

Parameters

Name Type
name T
execute (...args: ClientEvents[T]) => PluginResult

Returns

Plugin<unknown[]>

Defined in

src/handler/plugins/createPlugin.ts:45


EventControlPlugin

EventControlPlugin<I>(execute): Plugin<unknown[]>

Type parameters

Name Type
I extends EventType

Parameters

Name Type
execute (...args: EventArgs<I, Control>) => PluginResult

Returns

Plugin<unknown[]>

Defined in

src/handler/plugins/createPlugin.ts:34


EventInitPlugin

EventInitPlugin<I>(execute): Plugin<unknown[]>

Type parameters

Name Type
I extends EventType

Parameters

Name Type
execute (...args: EventArgs<I, Init>) => PluginResult

Returns

Plugin<unknown[]>

Defined in

src/handler/plugins/createPlugin.ts:16


commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

Name Type
mod InputCommand

Returns

CommandModule

Defined in

src/handler/sern.ts:65


discordEvent

discordEvent<T>(mod): EventModule

Create event modules from discord.js client events, This is an eventModule for discord events, where typings can be very bad.

Type parameters

Name Type
T extends keyof ClientEvents

Parameters

Name Type
mod Object
mod.execute (...args: ClientEvents[T]) => unknown
mod.name T
mod.plugins? AnyEventPlugin[]

Returns

EventModule

Defined in

src/handler/sern.ts:98


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

Name Type
mod InputEvent

Returns

EventModule

Defined in

src/handler/sern.ts:80


makePlugin

makePlugin<V>(type, execute): Plugin<V>

Type parameters

Name Type
V extends unknown[]

Parameters

Name Type
type PluginType
execute (...args: any[]) => any

Returns

Plugin<V>

Defined in

src/handler/plugins/createPlugin.ts:6


many

many<T>(value): () => () => T

A function that returns another function Used for transient in iti

Type parameters

Name
T

Parameters

Name Type
value T

Returns

fn

▸ (): () => T

Returns

fn

▸ (): T

Returns

T

Defined in

src/handler/utilities/functions.ts:17


single

single<T>(value): () => T

A function that returns whatever value is provided. Used for singleton in iti

Type parameters

Name
T

Parameters

Name Type
value T

Returns

fn

▸ (): T

Returns

T

Defined in

src/handler/utilities/functions.ts:10


useContainerRaw

useContainerRaw(): null | Container<Dependencies, Partial<Dependencies>>

Returns the underlying data structure holding all dependencies. Exposes some methods from iti

Returns

null | Container<Dependencies, Partial<Dependencies>>

Defined in

src/handler/dependencies/provider.ts:87