Files
archived-sern-website/docs/api/modules.md
Jacob Nguyen 49a910f90a fix docs build
2023-06-30 21:56:51 -05: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

References

controller

Re-exports controller

Type Aliases

AnyCommandPlugin

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

Defined in

src/core/types/plugins.ts:71


AnyEventPlugin

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

Defined in

src/core/types/plugins.ts:72


Args

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

Defined in

src/shared.ts:50


CommandModule

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

Defined in

src/core/types/modules.ts:133


EventModule

Ƭ EventModule: DiscordEventCommand | SernEventCommand | ExternalEventCommand

Defined in

src/core/types/modules.ts:132


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/shared.ts:14


PluginResult

Ƭ PluginResult: Awaitable<VoidResult>

Defined in

src/core/types/plugins.ts:50


SernOptionsData

Ƭ SernOptionsData: SernSubCommandData | SernSubCommandGroupData | APIApplicationCommandBasicOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/core/types/modules.ts:201


Singleton

Ƭ Singleton<T>: () => T

Type parameters

Name
T

Type declaration

▸ (): T

Returns

T

Defined in

src/core/ioc/types.ts:3


SlashOptions

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

Defined in

src/shared.ts:52


Transient

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

Type parameters

Name
T

Type declaration

▸ (): () => T

Returns

fn

▸ (): T

Returns

T

Defined in

src/core/ioc/types.ts:4

Functions

CommandControlPlugin

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

Since

2.5.0 @PURE

Type parameters

Name Type
I extends CommandType

Parameters

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

Returns

Plugin<unknown[]>

Defined in

src/core/create-plugins.ts:36


CommandInitPlugin

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

Since

2.5.0 @PURE

Type parameters

Name Type
I extends CommandType

Parameters

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

Returns

Plugin<unknown[]>

Defined in

src/core/create-plugins.ts:27


DiscordEventControlPlugin

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

Since

2.5.0

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


EventControlPlugin

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

Since

2.5.0 @PURE

Type parameters

Name Type
I extends EventType

Parameters

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

Returns

Plugin<unknown[]>

Defined in

src/core/create-plugins.ts:45


EventInitPlugin

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

Since

2.5.0 @PURE

Type parameters

Name Type
I extends EventType

Parameters

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

Returns

Plugin<unknown[]>

Defined in

src/core/create-plugins.ts:18


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.

Since

3.0.0

Example

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

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

Defined in

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


Services

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

Since

3.0.0 The plural version of Service

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

Defined in

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


commandModule

commandModule(mod): CommandModule

Since

1.0.0 The wrapper function to define command modules for sern

Parameters

Name Type
mod InputCommand

Returns

CommandModule

Defined in

src/handler/commands.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.

Experimental

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/commands.ts:53


eventModule

eventModule(mod): EventModule

Since

1.0.0 The wrapper function to define event modules for sern

Parameters

Name Type
mod InputEvent

Returns

EventModule

Defined in

src/handler/commands.ts:38


makeDependencies

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

Since

2.0.0

Type parameters

Name Type
T extends Dependencies

Parameters

Name Type Description
conf DependencyConfiguration a configuration for creating your project dependencies

Returns

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

Defined in

src/core/ioc/base.ts:25


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:5


single

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

@PURE

Since

2.0.0. Creates a singleton object.

Type parameters

Name
T

Parameters

Name Type
cb () => T

Returns

fn

▸ (): T

Returns

T

Defined in

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


transient

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

@PURE

Since

2.0.0 Creates a transient object

Type parameters

Name
T

Parameters

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

Returns

fn

▸ (): () => T

Returns

fn

▸ (): T

Returns

T

Defined in

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


useContainerRaw

useContainerRaw(): CoreContainer<Partial<Dependencies>>

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

Returns

CoreContainer<Partial<Dependencies>>

Defined in

src/core/ioc/base.ts:13