Files
website/docs/api/modules.md
2024-01-08 18:32:17 +00:00

16 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/core-plugin.ts:76


AnyEventPlugin

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

Defined in

src/types/core-plugin.ts:77


Args

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

Defined in

src/types/utility.ts:16


CommandModule

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

Defined in

src/types/core-modules.ts:133


EventModule

Ƭ EventModule: DiscordEventCommand | SernEventCommand | ExternalEventCommand

Defined in

src/types/core-modules.ts:132


Initializable

Ƭ Initializable<T>: T

Type to annotate that something is initializable. If T has an init method, this will be called.

Type parameters

Name Type
T extends Init

Defined in

src/types/ioc.ts:17


LogPayload

Ƭ LogPayload<T>: Object

Type parameters

Name Type
T unknown

Type declaration

Name Type
message T

Defined in

src/core/contracts/logging.ts:11


Payload

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

Defined in

src/types/utility.ts:26


PluginResult

Ƭ PluginResult: Awaitable<VoidResult>

Defined in

src/types/core-plugin.ts:51


SernOptionsData

Ƭ SernOptionsData: SernSubCommandData | SernSubCommandGroupData | APIApplicationCommandBasicOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/types/core-modules.ts:201


Singleton

Ƭ Singleton<T>: () => T

Type parameters

Name
T

Type declaration

▸ (): T

Type to annotate that something is a singleton. T is created once and lazily.

Returns

T

Defined in

src/types/ioc.ts:7


SlashOptions

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

Defined in

src/types/utility.ts:14


Transient

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

Type parameters

Name
T

Type declaration

▸ (): () => T

Type to annotate that something is transient. Every time this is called, a new object is created

Returns

fn

▸ (): T

Returns

T

Defined in

src/types/ioc.ts:12

Variables

controller

Const controller: Object

Since

1.0.0 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/core/create-plugins.ts:69

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[]>

Since

2.5.0 @PURE

Defined in

src/core/create-plugins.ts:37


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[]>

Since

2.5.0 @PURE

Defined in

src/core/create-plugins.ts:28


DiscordEventControlPlugin

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

Type parameters

Name Type
T extends keyof ClientEvents

Parameters

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

Returns

Plugin<unknown[]>

Since

2.5.0

Experimental

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

Defined in

src/core/create-plugins.ts:58


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[]>

Since

2.5.0 @PURE

Defined in

src/core/create-plugins.ts:46


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[]>

Since

2.5.0 @PURE

Defined in

src/core/create-plugins.ts:19


Service

Service<T>(key): NonNullable<UnpackFunction<Partial<Dependencies>[T]>>

The new Service api, a cleaner alternative to useContainer To obtain intellisense, ensure a .d.ts file exists in the root of compilation. Usually our scaffolding tool takes care of this.

Type parameters

Name Type
T extends keyof Dependencies

Parameters

Name Type Description
key T a key that corresponds to a dependency registered.

Returns

NonNullable<UnpackFunction<Partial<Dependencies>[T]>>

Since

3.0.0

Example

const client = Service('@sern/client');

Defined in

src/core/ioc/dependency-injection.ts:36


Services

Services<T>(...keys): IntoDependencies<T>

Type parameters

Name Type
T extends keyof Dependencies[]

Parameters

Name Type
...keys [...T[]]

Returns

IntoDependencies<T>

array of dependencies, in the same order of keys provided

Since

3.0.0 The plural version of Service

Defined in

src/core/ioc/dependency-injection.ts:44


commandModule

commandModule(mod): CommandModule

Parameters

Name Type
mod InputCommand

Returns

CommandModule

Since

1.0.0 The wrapper function to define command modules for sern

Defined in

src/core/modules.ts:25


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

Experimental

Defined in

src/core/modules.ts:53


eventModule

eventModule(mod): EventModule

Parameters

Name Type
mod InputEvent

Returns

EventModule

Since

1.0.0 The wrapper function to define event modules for sern

Defined in

src/core/modules.ts:38


makeDependencies

makeDependencies<T>(conf): Promise<<V>(...keys: [...V[]]) => IntoDependencies<V>>

Type parameters

Name Type
T extends Dependencies

Parameters

Name Type
conf ValidDependencyConfig

Returns

Promise<<V>(...keys: [...V[]]) => IntoDependencies<V>>

Defined in

src/core/ioc/base.ts:90


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/core/create-plugins.ts:6


single

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

@PURE

Type parameters

Name
T

Parameters

Name Type
cb () => T

Returns

fn

▸ (): T

Returns

T

Since

2.0.0. Creates a singleton object.

Defined in

src/core/ioc/dependency-injection.ts:11


transient

transient<T>(cb): () => () => T

@PURE

Type parameters

Name
T

Parameters

Name Type
cb () => () => T

Returns

fn

▸ (): () => T

Returns

fn

▸ (): T

Returns

T

Since

2.0.0 Creates a transient object

Defined in

src/core/ioc/dependency-injection.ts:21


useContainerRaw

useContainerRaw(): CoreContainer<Partial<Dependencies>>

Returns

CoreContainer<Partial<Dependencies>>

Deprecated

Returns the underlying data structure holding all dependencies. Exposes methods from iti Use the Service API. The container should be readonly

Defined in

src/core/ioc/base.ts:18