feat: migrate to starlight

This commit is contained in:
DuroCodes
2024-05-06 17:15:30 -04:00
parent 767acedea7
commit bb190f2d81
15140 changed files with 2828326 additions and 35408 deletions

7
src/content/config.ts Normal file
View File

@@ -0,0 +1,7 @@
import { defineCollection } from "astro:content";
import { docsSchema } from "@astrojs/starlight/schema";
import { blogSchema } from "starlight-blog/schema";
export const collections = {
docs: defineCollection({ schema: docsSchema({ extend: blogSchema() }) }),
};

View File

@@ -0,0 +1,96 @@
---
editUrl: false
next: false
prev: false
title: "@sern/handler"
---
## Namespaces
- [Presence](/api/namespaces/presence/readme/)
- [Sern](/api/namespaces/sern/readme/)
## Enumerations
- [CommandType](/api/enumerations/commandtype/)
- [EventType](/api/enumerations/eventtype/)
- [PayloadType](/api/enumerations/payloadtype/)
- [PluginType](/api/enumerations/plugintype/)
## Classes
- [Context](/api/classes/context/)
- [ModuleStore](/api/classes/modulestore/)
## Interfaces
- [BothCommand](/api/interfaces/bothcommand/)
- [ButtonCommand](/api/interfaces/buttoncommand/)
- [ChannelSelectCommand](/api/interfaces/channelselectcommand/)
- [CommandModuleDefs](/api/interfaces/commandmoduledefs/)
- [ContextMenuMsg](/api/interfaces/contextmenumsg/)
- [ContextMenuUser](/api/interfaces/contextmenuuser/)
- [ControlPlugin](/api/interfaces/controlplugin/)
- [Controller](/api/interfaces/controller/)
- [CoreDependencies](/api/interfaces/coredependencies/)
- [CoreModuleStore](/api/interfaces/coremodulestore/)
- [DiscordEventCommand](/api/interfaces/discordeventcommand/)
- [Disposable](/api/interfaces/disposable/)
- [Emitter](/api/interfaces/emitter/)
- [ErrorHandling](/api/interfaces/errorhandling/)
- [EventModuleDefs](/api/interfaces/eventmoduledefs/)
- [ExternalEventCommand](/api/interfaces/externaleventcommand/)
- [Init](/api/interfaces/init/)
- [InitPlugin](/api/interfaces/initplugin/)
- [Logging](/api/interfaces/logging/)
- [MentionableSelectCommand](/api/interfaces/mentionableselectcommand/)
- [ModalSubmitCommand](/api/interfaces/modalsubmitcommand/)
- [Plugin](/api/interfaces/plugin/)
- [RoleSelectCommand](/api/interfaces/roleselectcommand/)
- [SernAutocompleteData](/api/interfaces/sernautocompletedata/)
- [SernEventCommand](/api/interfaces/serneventcommand/)
- [SernEventsMapping](/api/interfaces/serneventsmapping/)
- [SernSubCommandData](/api/interfaces/sernsubcommanddata/)
- [SernSubCommandGroupData](/api/interfaces/sernsubcommandgroupdata/)
- [SlashCommand](/api/interfaces/slashcommand/)
- [StringSelectCommand](/api/interfaces/stringselectcommand/)
- [TextCommand](/api/interfaces/textcommand/)
- [UserSelectCommand](/api/interfaces/userselectcommand/)
- [Wrapper](/api/interfaces/wrapper/)
## Type Aliases
- [AnyCommandPlugin](/api/type-aliases/anycommandplugin/)
- [AnyEventPlugin](/api/type-aliases/anyeventplugin/)
- [Args](/api/type-aliases/args/)
- [CommandModule](/api/type-aliases/commandmodule/)
- [EventModule](/api/type-aliases/eventmodule/)
- [Initializable](/api/type-aliases/initializable/)
- [LogPayload](/api/type-aliases/logpayload/)
- [Payload](/api/type-aliases/payload/)
- [PluginResult](/api/type-aliases/pluginresult/)
- [SernOptionsData](/api/type-aliases/sernoptionsdata/)
- [Singleton](/api/type-aliases/singleton/)
- [SlashOptions](/api/type-aliases/slashoptions/)
- [Transient](/api/type-aliases/transient/)
## Variables
- [controller](/api/variables/controller/)
## Functions
- [CommandControlPlugin](/api/functions/commandcontrolplugin/)
- [CommandInitPlugin](/api/functions/commandinitplugin/)
- [DiscordEventControlPlugin](/api/functions/discordeventcontrolplugin/)
- [EventControlPlugin](/api/functions/eventcontrolplugin/)
- [EventInitPlugin](/api/functions/eventinitplugin/)
- [Service](/api/functions/service/)
- [Services](/api/functions/services/)
- [commandModule](/api/functions/commandmodule/)
- [discordEvent](/api/functions/discordevent/)
- [eventModule](/api/functions/eventmodule/)
- [makeDependencies](/api/functions/makedependencies/)
- [makePlugin](/api/functions/makeplugin/)
- [single](/api/functions/single/)
- [transient](/api/functions/transient/)

View File

@@ -0,0 +1,291 @@
---
editUrl: false
next: false
prev: false
title: "Context"
---
## Since
1.0.0
Provides values shared between
Message and ChatInputCommandInteraction
## Extends
- `CoreContext`\<`Message`, `ChatInputCommandInteraction`\>
## Accessors
### channel
> `get` **channel**(): `null` \| `TextBasedChannel`
#### Returns
`null` \| `TextBasedChannel`
#### Source
[src/core/structures/context.ts:39](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L39)
***
### channelId
> `get` **channelId**(): `string`
#### Returns
`string`
#### Source
[src/core/structures/context.ts:45](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L45)
***
### client
> `get` **client**(): `Client`\<`boolean`\>
#### Returns
`Client`\<`boolean`\>
#### Source
[src/core/structures/context.ts:91](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L91)
***
### createdTimestamp
> `get` **createdTimestamp**(): `number`
#### Returns
`number`
#### Source
[src/core/structures/context.ts:65](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L65)
***
### guild
> `get` **guild**(): `null` \| `Guild`
#### Returns
`null` \| `Guild`
#### Source
[src/core/structures/context.ts:71](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L71)
***
### guildId
> `get` **guildId**(): `null` \| `string`
#### Returns
`null` \| `string`
#### Source
[src/core/structures/context.ts:77](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L77)
***
### id
> `get` **id**(): `string`
#### Returns
`string`
#### Source
[src/core/structures/context.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L33)
***
### inGuild
> `get` **inGuild**(): `boolean`
#### Returns
`boolean`
#### Source
[src/core/structures/context.ts:97](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L97)
***
### interaction
> `get` **interaction**(): `I`
#### Returns
`I`
#### Source
[src/core/structures/core-context.ts:15](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/core-context.ts#L15)
***
### member
> `get` **member**(): `null` \| `GuildMember` \| `APIInteractionGuildMember`
#### Returns
`null` \| `GuildMember` \| `APIInteractionGuildMember`
#### Source
[src/core/structures/context.ts:85](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L85)
***
### message
> `get` **message**(): `M`
#### Returns
`M`
#### Source
[src/core/structures/core-context.ts:12](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/core-context.ts#L12)
***
### options
> `get` **options**(): `Omit`\<`CommandInteractionOptionResolver`\<`CacheType`\>, `"getMessage"` \| `"getFocused"`\>
#### Returns
`Omit`\<`CommandInteractionOptionResolver`\<`CacheType`\>, `"getMessage"` \| `"getFocused"`\>
#### Source
[src/core/structures/context.ts:26](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L26)
***
### user
> `get` **user**(): `User`
If context is holding a message, message.author
else, interaction.user
#### Returns
`User`
#### Source
[src/core/structures/context.ts:55](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L55)
***
### userId
> `get` **userId**(): `string`
#### Returns
`string`
#### Source
[src/core/structures/context.ts:61](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L61)
## Methods
### isMessage()
> **isMessage**(): `this is CoreContext<Message<boolean>, never>`
#### Returns
`this is CoreContext<Message<boolean>, never>`
#### Inherited from
`CoreContext.isMessage`
#### Source
[src/core/structures/core-context.ts:19](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/core-context.ts#L19)
***
### isSlash()
> **isSlash**(): `this is CoreContext<never, ChatInputCommandInteraction<CacheType>>`
#### Returns
`this is CoreContext<never, ChatInputCommandInteraction<CacheType>>`
#### Inherited from
`CoreContext.isSlash`
#### Source
[src/core/structures/core-context.ts:23](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/core-context.ts#L23)
***
### reply()
> **reply**(`content`): `Promise`\<`Message`\<`boolean`\>\>
#### Parameters
**content**: `ReplyOptions`
#### Returns
`Promise`\<`Message`\<`boolean`\>\>
#### Source
[src/core/structures/context.ts:103](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L103)
***
### wrap()
> `static` **wrap**(`wrappable`): [`Context`](/api/classes/context/)
#### Parameters
**wrappable**: `Message`\<`boolean`\> \| `BaseInteraction`\<`CacheType`\>
#### Returns
[`Context`](/api/classes/context/)
#### Overrides
`CoreContext.wrap`
#### Source
[src/core/structures/context.ts:113](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/context.ts#L113)

View File

@@ -0,0 +1,36 @@
---
editUrl: false
next: false
prev: false
title: "ModuleStore"
---
## Constructors
### new ModuleStore()
> **new ModuleStore**(): [`ModuleStore`](/api/classes/modulestore/)
#### Returns
[`ModuleStore`](/api/classes/modulestore/)
## Properties
### commands
> **commands**: `Map`\<`string`, `Module`\>
#### Source
[src/core/structures/module-store.ts:10](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/module-store.ts#L10)
***
### metadata
> **metadata**: `WeakMap`\<`Module`, `CommandMeta`\>
#### Source
[src/core/structures/module-store.ts:9](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/module-store.ts#L9)

View File

@@ -0,0 +1,144 @@
---
editUrl: false
next: false
prev: false
title: "CommandType"
---
## Since
1.0.0
A bitfield that discriminates command modules
## Example
```ts
export default commandModule({
// highlight-next-line
type : CommandType.Text,
name : 'a text command'
execute(message) {
console.log(message.content)
}
})
```
## Enumeration Members
### Both
> **Both**: `3`
#### Source
[src/core/structures/enums.ts:20](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L20)
***
### Button
> **Button**: `16`
#### Source
[src/core/structures/enums.ts:23](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L23)
***
### ChannelSelect
> **ChannelSelect**: `1024`
#### Source
[src/core/structures/enums.ts:29](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L29)
***
### CtxMsg
> **CtxMsg**: `8`
#### Source
[src/core/structures/enums.ts:22](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L22)
***
### CtxUser
> **CtxUser**: `4`
#### Source
[src/core/structures/enums.ts:21](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L21)
***
### MentionableSelect
> **MentionableSelect**: `512`
#### Source
[src/core/structures/enums.ts:28](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L28)
***
### Modal
> **Modal**: `64`
#### Source
[src/core/structures/enums.ts:25](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L25)
***
### RoleSelect
> **RoleSelect**: `256`
#### Source
[src/core/structures/enums.ts:27](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L27)
***
### Slash
> **Slash**: `2`
#### Source
[src/core/structures/enums.ts:19](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L19)
***
### StringSelect
> **StringSelect**: `32`
#### Source
[src/core/structures/enums.ts:24](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L24)
***
### Text
> **Text**: `1`
#### Source
[src/core/structures/enums.ts:18](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L18)
***
### UserSelect
> **UserSelect**: `128`
#### Source
[src/core/structures/enums.ts:26](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L26)

View File

@@ -0,0 +1,58 @@
---
editUrl: false
next: false
prev: false
title: "EventType"
---
A bitfield that discriminates event modules
## Example
```ts
export default eventModule({
//highlight-next-line
type : EventType.Discord,
name : 'guildMemberAdd'
execute(member : GuildMember) {
console.log(member)
}
})
```
## Enumeration Members
### Discord
> **Discord**: `1`
The EventType for handling discord events
#### Source
[src/core/structures/enums.ts:51](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L51)
***
### External
> **External**: `3`
The EventType for handling external events.
Could be for example, `process` events, database events
#### Source
[src/core/structures/enums.ts:60](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L60)
***
### Sern
> **Sern**: `2`
The EventType for handling sern events
#### Source
[src/core/structures/enums.ts:55](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L55)

View File

@@ -0,0 +1,42 @@
---
editUrl: false
next: false
prev: false
title: "PayloadType"
---
## Enumeration Members
### Failure
> **Failure**: `"failure"`
The PayloadType for a SernEmitter failure event
#### Source
[src/core/structures/enums.ts:98](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L98)
***
### Success
> **Success**: `"success"`
The PayloadType for a SernEmitter success event
#### Source
[src/core/structures/enums.ts:94](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L94)
***
### Warning
> **Warning**: `"warning"`
The PayloadType for a SernEmitter warning event
#### Source
[src/core/structures/enums.ts:102](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L102)

View File

@@ -0,0 +1,44 @@
---
editUrl: false
next: false
prev: false
title: "PluginType"
---
A bitfield that discriminates plugins
## Example
```ts
export default function myPlugin() : EventPlugin<CommandType.Text> {
//highlight-next-line
type : PluginType.Event,
execute([ctx, args], controller) {
return controller.next();
}
}
```
## Enumeration Members
### Control
> **Control**: `2`
The PluginType for EventPlugins
#### Source
[src/core/structures/enums.ts:85](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L85)
***
### Init
> **Init**: `1`
The PluginType for InitPlugins
#### Source
[src/core/structures/enums.ts:81](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/structures/enums.ts#L81)

View File

@@ -0,0 +1,29 @@
---
editUrl: false
next: false
prev: false
title: "CommandControlPlugin"
---
> **CommandControlPlugin**\<`I`\>(`execute`): [`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Type parameters
**I** *extends* [`CommandType`](/api/enumerations/commandtype/)
## Parameters
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Since
2.5.0
@__PURE__
## Source
[src/core/create-plugins.ts:37](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L37)

View File

@@ -0,0 +1,29 @@
---
editUrl: false
next: false
prev: false
title: "CommandInitPlugin"
---
> **CommandInitPlugin**\<`I`\>(`execute`): [`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Type parameters
**I** *extends* [`CommandType`](/api/enumerations/commandtype/)
## Parameters
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Since
2.5.0
@__PURE__
## Source
[src/core/create-plugins.ts:28](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L28)

View File

@@ -0,0 +1,35 @@
---
editUrl: false
next: false
prev: false
title: "DiscordEventControlPlugin"
---
> **DiscordEventControlPlugin**\<`T`\>(`name`, `execute`): [`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Type parameters
**T** *extends* keyof `ClientEvents`
## Parameters
**name**: `T`
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Since
2.5.0
## Experimental
A specialized function for creating control plugins with discord.js ClientEvents.
Will probably be moved one day!
## Source
[src/core/create-plugins.ts:58](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L58)

View File

@@ -0,0 +1,29 @@
---
editUrl: false
next: false
prev: false
title: "EventControlPlugin"
---
> **EventControlPlugin**\<`I`\>(`execute`): [`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Type parameters
**I** *extends* [`EventType`](/api/enumerations/eventtype/)
## Parameters
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Since
2.5.0
@__PURE__
## Source
[src/core/create-plugins.ts:46](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L46)

View File

@@ -0,0 +1,29 @@
---
editUrl: false
next: false
prev: false
title: "EventInitPlugin"
---
> **EventInitPlugin**\<`I`\>(`execute`): [`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Type parameters
**I** *extends* [`EventType`](/api/enumerations/eventtype/)
## Parameters
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`unknown`[]\>
## Since
2.5.0
@__PURE__
## Source
[src/core/create-plugins.ts:19](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L19)

View File

@@ -0,0 +1,41 @@
---
editUrl: false
next: false
prev: false
title: "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.
Note: this method only works AFTER your container has been initiated
## Type parameters
**T** *extends* keyof `Dependencies`
## Parameters
**key**: `T`
a key that corresponds to a dependency registered.
## Returns
`NonNullable`\<`UnpackFunction`\<`Partial`\<`Dependencies`\>\[`T`\]\>\>
## Since
3.0.0
## Example
```ts
const client = Service('@sern/client');
```
## Source
[src/core/ioc/dependency-injection.ts:37](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/ioc/dependency-injection.ts#L37)

View File

@@ -0,0 +1,31 @@
---
editUrl: false
next: false
prev: false
title: "Services"
---
> **Services**\<`T`\>(...`keys`): `IntoDependencies`\<`T`\>
## Type parameters
**T** *extends* keyof `Dependencies`[]
## Parameters
• ...**keys**: [`...T[]`]
## Returns
`IntoDependencies`\<`T`\>
array of dependencies, in the same order of keys provided
## Since
3.0.0
The plural version of [Service](../../../../../../api/functions/service)
## Source
[src/core/ioc/dependency-injection.ts:47](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/ioc/dependency-injection.ts#L47)

View File

@@ -0,0 +1,24 @@
---
editUrl: false
next: false
prev: false
title: "commandModule"
---
> **commandModule**(`mod`): [`CommandModule`](/api/type-aliases/commandmodule/)
## Parameters
**mod**: `InputCommand`
## Returns
[`CommandModule`](/api/type-aliases/commandmodule/)
## Since
1.0.0 The wrapper function to define command modules for sern
## Source
[src/core/modules.ts:19](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/modules.ts#L19)

View File

@@ -0,0 +1,36 @@
---
editUrl: false
next: false
prev: false
title: "discordEvent"
---
> **discordEvent**\<`T`\>(`mod`): [`EventModule`](/api/type-aliases/eventmodule/)
Create event modules from discord.js client events,
This is an [eventModule](../../../../../../api/functions/eventmodule) for discord events,
where typings can be very bad.
## Type parameters
**T** *extends* keyof `ClientEvents`
## Parameters
**mod**
**mod.execute**
**mod.name**: `T`
**mod.plugins?**: [`AnyEventPlugin`](/api/type-aliases/anyeventplugin/)[]
## Returns
[`EventModule`](/api/type-aliases/eventmodule/)
## Experimental
## Source
[src/core/modules.ts:47](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/modules.ts#L47)

View File

@@ -0,0 +1,25 @@
---
editUrl: false
next: false
prev: false
title: "eventModule"
---
> **eventModule**(`mod`): [`EventModule`](/api/type-aliases/eventmodule/)
## Parameters
**mod**: `InputEvent`
## Returns
[`EventModule`](/api/type-aliases/eventmodule/)
## Since
1.0.0
The wrapper function to define event modules for sern
## Source
[src/core/modules.ts:32](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/modules.ts#L32)

View File

@@ -0,0 +1,24 @@
---
editUrl: false
next: false
prev: false
title: "makeDependencies"
---
> **makeDependencies**\<`T`\>(`conf`): `Promise`\<\<`V`\>(...`keys`) => `IntoDependencies`\<`V`\>\>
## Type parameters
**T** *extends* `Dependencies`
## Parameters
**conf**: `ValidDependencyConfig`
## Returns
`Promise`\<\<`V`\>(...`keys`) => `IntoDependencies`\<`V`\>\>
## Source
[src/core/ioc/base.ts:144](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/ioc/base.ts#L144)

View File

@@ -0,0 +1,26 @@
---
editUrl: false
next: false
prev: false
title: "makePlugin"
---
> **makePlugin**\<`V`\>(`type`, `execute`): [`Plugin`](/api/interfaces/plugin/)\<`V`\>
## Type parameters
**V** *extends* `unknown`[]
## Parameters
**type**: [`PluginType`](/api/enumerations/plugintype/)
**execute**
## Returns
[`Plugin`](/api/interfaces/plugin/)\<`V`\>
## Source
[src/core/create-plugins.ts:6](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L6)

View File

@@ -0,0 +1,35 @@
---
editUrl: false
next: false
prev: false
title: "single"
---
> **single**\<`T`\>(`cb`): () => `T`
@__PURE__
## Type parameters
**T**
## Parameters
**cb**
## Returns
`Function`
### Returns
`T`
## Since
2.0.0.
Creates a singleton object.
## Source
[src/core/ioc/dependency-injection.ts:11](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/ioc/dependency-injection.ts#L11)

View File

@@ -0,0 +1,39 @@
---
editUrl: false
next: false
prev: false
title: "transient"
---
> **transient**\<`T`\>(`cb`): () => () => `T`
@__PURE__
## Type parameters
**T**
## Parameters
**cb**
## Returns
`Function`
### Returns
`Function`
#### Returns
`T`
## Since
2.0.0
Creates a transient object
## Source
[src/core/ioc/dependency-injection.ts:21](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/ioc/dependency-injection.ts#L21)

View File

@@ -0,0 +1,124 @@
---
editUrl: false
next: false
prev: false
title: "BothCommand"
---
## Extends
- `Module`
## Properties
### alias?
> `optional` **alias**: `string`[]
#### Source
[src/types/core-modules.ts:125](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L125)
***
### description
> **description**: `string`
#### Overrides
`Module.description`
#### Source
[src/types/core-modules.ts:126](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L126)
***
### execute()
> **execute**: (`ctx`, `args`) => `unknown`
#### Parameters
**ctx**: [`Context`](/api/classes/context/)
**args**: [`Args`](/api/type-aliases/args/)
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:128](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L128)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### options?
> `optional` **options**: [`SernOptionsData`](/api/type-aliases/sernoptionsdata/)[]
#### Source
[src/types/core-modules.ts:127](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L127)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Both`](/api/enumerations/commandtype/#both)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:124](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L124)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "ButtonCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `ButtonInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:65](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L65)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Button`](/api/enumerations/commandtype/#button)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:64](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L64)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "ChannelSelectCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `ChannelSelectMenuInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:75](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L75)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`ChannelSelect`](/api/enumerations/commandtype/#channelselect)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:74](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L74)

View File

@@ -0,0 +1,126 @@
---
editUrl: false
next: false
prev: false
title: "CommandModuleDefs"
---
## Properties
### 1
> **1**: [`TextCommand`](/api/interfaces/textcommand/)
#### Source
[src/types/core-modules.ts:150](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L150)
***
### 1024
> **1024**: [`ChannelSelectCommand`](/api/interfaces/channelselectcommand/)
#### Source
[src/types/core-modules.ts:158](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L158)
***
### 128
> **128**: [`UserSelectCommand`](/api/interfaces/userselectcommand/)
#### Source
[src/types/core-modules.ts:160](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L160)
***
### 16
> **16**: [`ButtonCommand`](/api/interfaces/buttoncommand/)
#### Source
[src/types/core-modules.ts:155](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L155)
***
### 2
> **2**: [`SlashCommand`](/api/interfaces/slashcommand/)
#### Source
[src/types/core-modules.ts:151](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L151)
***
### 256
> **256**: [`RoleSelectCommand`](/api/interfaces/roleselectcommand/)
#### Source
[src/types/core-modules.ts:157](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L157)
***
### 3
> **3**: [`BothCommand`](/api/interfaces/bothcommand/)
#### Source
[src/types/core-modules.ts:152](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L152)
***
### 32
> **32**: [`StringSelectCommand`](/api/interfaces/stringselectcommand/)
#### Source
[src/types/core-modules.ts:156](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L156)
***
### 4
> **4**: [`ContextMenuUser`](/api/interfaces/contextmenuuser/)
#### Source
[src/types/core-modules.ts:154](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L154)
***
### 512
> **512**: [`MentionableSelectCommand`](/api/interfaces/mentionableselectcommand/)
#### Source
[src/types/core-modules.ts:159](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L159)
***
### 64
> **64**: [`ModalSubmitCommand`](/api/interfaces/modalsubmitcommand/)
#### Source
[src/types/core-modules.ts:161](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L161)
***
### 8
> **8**: [`ContextMenuMsg`](/api/interfaces/contextmenumsg/)
#### Source
[src/types/core-modules.ts:153](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L153)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "ContextMenuMsg"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `MessageContextMenuCommandInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:60](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L60)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`CtxMsg`](/api/enumerations/commandtype/#ctxmsg)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:59](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L59)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "ContextMenuUser"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `UserContextMenuCommandInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:55](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L55)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`CtxUser`](/api/enumerations/commandtype/#ctxuser)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:54](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L54)

View File

@@ -0,0 +1,38 @@
---
editUrl: false
next: false
prev: false
title: "ControlPlugin"
---
## Type parameters
**Args** *extends* `any`[] = `any`[]
## Properties
### execute()
> **execute**: (...`args`) => [`PluginResult`](/api/type-aliases/pluginresult/)
#### Parameters
• ...**args**: `Args`
#### Returns
[`PluginResult`](/api/type-aliases/pluginresult/)
#### Source
[src/types/core-plugin.ts:73](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L73)
***
### type
> **type**: [`Control`](/api/enumerations/plugintype/#control)
#### Source
[src/types/core-plugin.ts:72](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L72)

View File

@@ -0,0 +1,34 @@
---
editUrl: false
next: false
prev: false
title: "Controller"
---
## Properties
### next()
> **next**: () => `Ok`\<`void`\>
#### Returns
`Ok`\<`void`\>
#### Source
[src/types/core-plugin.ts:59](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L59)
***
### stop()
> **stop**: () => `Err`\<`void`\>
#### Returns
`Err`\<`void`\>
#### Source
[src/types/core-plugin.ts:60](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L60)

View File

@@ -0,0 +1,94 @@
---
editUrl: false
next: false
prev: false
title: "CoreDependencies"
---
## Properties
### @sern/client()
> **@sern/client**: () => [`Emitter`](/api/interfaces/emitter/)
#### Returns
[`Emitter`](/api/interfaces/emitter/)
#### Source
[src/types/ioc.ts:28](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L28)
***
### @sern/emitter()
> **@sern/emitter**: () => [`Emitter`](/api/interfaces/emitter/)
#### Returns
[`Emitter`](/api/interfaces/emitter/)
#### Source
[src/types/ioc.ts:29](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L29)
***
### @sern/errors()
> **@sern/errors**: () => [`ErrorHandling`](/api/interfaces/errorhandling/)
#### Returns
[`ErrorHandling`](/api/interfaces/errorhandling/)
#### Source
[src/types/ioc.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L36)
***
### @sern/logger()?
> `optional` **@sern/logger**: () => [`Logging`](/api/interfaces/logging/)\<`unknown`\>
#### Returns
[`Logging`](/api/interfaces/logging/)\<`unknown`\>
#### Source
[src/types/ioc.ts:37](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L37)
***
### @sern/modules()
> **@sern/modules**: () => `ModuleManager`
#### Returns
`ModuleManager`
#### Source
[src/types/ioc.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L35)
***
### ~~@sern/store()~~
> **@sern/store**: () => [`CoreModuleStore`](/api/interfaces/coremodulestore/)
:::caution[Deprecated]
Will be removed and turned internal
:::
#### Returns
[`CoreModuleStore`](/api/interfaces/coremodulestore/)
#### Source
[src/types/ioc.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L34)

View File

@@ -0,0 +1,28 @@
---
editUrl: false
next: false
prev: false
title: "CoreModuleStore"
---
Represents a core module store that stores IDs mapped to file paths.
## Properties
### commands
> **commands**: `Map`\<`string`, `Module`\>
#### Source
[src/core/contracts/module-store.ts:7](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/module-store.ts#L7)
***
### metadata
> **metadata**: `WeakMap`\<`Module`, `CommandMeta`\>
#### Source
[src/core/contracts/module-store.ts:8](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/module-store.ts#L8)

View File

@@ -0,0 +1,106 @@
---
editUrl: false
next: false
prev: false
title: "DiscordEventCommand"
---
## Extends
- `Module`
## Type parameters
**T** *extends* keyof `ClientEvents` = keyof `ClientEvents`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### name?
> `optional` **name**: `T`
#### Overrides
`Module.name`
#### Source
[src/types/core-modules.ts:106](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L106)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Discord`](/api/enumerations/eventtype/#discord)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:107](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L107)
## Methods
### execute()
> **execute**(...`args`): `unknown`
#### Parameters
• ...**args**: `ClientEvents`\[`T`\]
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:108](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L108)

View File

@@ -0,0 +1,23 @@
---
editUrl: false
next: false
prev: false
title: "Disposable"
---
Represents a Disposable contract.
Let dependencies implement this to dispose and cleanup.
## Methods
### dispose()
> **dispose**(): `unknown`
#### Returns
`unknown`
#### Source
[src/core/contracts/hooks.ts:15](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/hooks.ts#L15)

View File

@@ -0,0 +1,66 @@
---
editUrl: false
next: false
prev: false
title: "Emitter"
---
## Methods
### addListener()
> **addListener**(`eventName`, `listener`): `this`
#### Parameters
**eventName**: `string` \| `symbol`
**listener**: `AnyFunction`
#### Returns
`this`
#### Source
[src/core/contracts/emitter.ts:6](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/emitter.ts#L6)
***
### emit()
> **emit**(`eventName`, ...`payload`): `boolean`
#### Parameters
**eventName**: `string` \| `symbol`
• ...**payload**: `any`[]
#### Returns
`boolean`
#### Source
[src/core/contracts/emitter.ts:8](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/emitter.ts#L8)
***
### removeListener()
> **removeListener**(`eventName`, `listener`): `this`
#### Parameters
**eventName**: `string` \| `symbol`
**listener**: `AnyFunction`
#### Returns
`this`
#### Source
[src/core/contracts/emitter.ts:7](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/emitter.ts#L7)

View File

@@ -0,0 +1,52 @@
---
editUrl: false
next: false
prev: false
title: "ErrorHandling"
---
## Since
2.0.0
## Methods
### ~~crash()~~
> **crash**(`err`): `never`
:::caution[Deprecated]
Version 4 will remove this method
:::
#### Parameters
**err**: `Error`
#### Returns
`never`
#### Source
[src/core/contracts/error-handling.ts:9](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/error-handling.ts#L9)
***
### updateAlive()
> **updateAlive**(`error`): `void`
A function that is called on every throw.
#### Parameters
**error**: `Error`
#### Returns
`void`
#### Source
[src/core/contracts/error-handling.ts:14](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/error-handling.ts#L14)

View File

@@ -0,0 +1,36 @@
---
editUrl: false
next: false
prev: false
title: "EventModuleDefs"
---
## Properties
### 1
> **1**: [`DiscordEventCommand`](/api/interfaces/discordeventcommand/)\<keyof `ClientEvents`\>
#### Source
[src/types/core-modules.ts:166](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L166)
***
### 2
> **2**: [`SernEventCommand`](/api/interfaces/serneventcommand/)\<keyof [`SernEventsMapping`](/api/interfaces/serneventsmapping/)\>
#### Source
[src/types/core-modules.ts:165](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L165)
***
### 3
> **3**: [`ExternalEventCommand`](/api/interfaces/externaleventcommand/)
#### Source
[src/types/core-modules.ts:167](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L167)

View File

@@ -0,0 +1,112 @@
---
editUrl: false
next: false
prev: false
title: "ExternalEventCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### emitter
> **emitter**: keyof `Dependencies`
#### Source
[src/types/core-modules.ts:48](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L48)
***
### name?
> `optional` **name**: `string`
#### Overrides
`Module.name`
#### Source
[src/types/core-modules.ts:47](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L47)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`External`](/api/enumerations/eventtype/#external)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:49](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L49)
## Methods
### execute()
> **execute**(...`args`): `unknown`
#### Parameters
• ...**args**: `unknown`[]
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:50](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L50)

View File

@@ -0,0 +1,23 @@
---
editUrl: false
next: false
prev: false
title: "Init"
---
Represents an initialization contract.
Let dependencies implement this to initiate some logic.
## Methods
### init()
> **init**(): `unknown`
#### Returns
`unknown`
#### Source
[src/core/contracts/hooks.ts:7](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/hooks.ts#L7)

View File

@@ -0,0 +1,38 @@
---
editUrl: false
next: false
prev: false
title: "InitPlugin"
---
## Type parameters
**Args** *extends* `any`[] = `any`[]
## Properties
### execute()
> **execute**: (...`args`) => [`PluginResult`](/api/type-aliases/pluginresult/)
#### Parameters
• ...**args**: `Args`
#### Returns
[`PluginResult`](/api/type-aliases/pluginresult/)
#### Source
[src/types/core-plugin.ts:69](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L69)
***
### type
> **type**: [`Init`](/api/enumerations/plugintype/#init)
#### Source
[src/types/core-plugin.ts:68](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L68)

View File

@@ -0,0 +1,86 @@
---
editUrl: false
next: false
prev: false
title: "Logging"
---
## Since
2.0.0
## Type parameters
**T** = `unknown`
## Methods
### debug()
> **debug**(`payload`): `void`
#### Parameters
**payload**: [`LogPayload`](/api/type-aliases/logpayload/)\<`T`\>
#### Returns
`void`
#### Source
[src/core/contracts/logging.ts:8](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/logging.ts#L8)
***
### error()
> **error**(`payload`): `void`
#### Parameters
**payload**: [`LogPayload`](/api/type-aliases/logpayload/)\<`T`\>
#### Returns
`void`
#### Source
[src/core/contracts/logging.ts:5](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/logging.ts#L5)
***
### info()
> **info**(`payload`): `void`
#### Parameters
**payload**: [`LogPayload`](/api/type-aliases/logpayload/)\<`T`\>
#### Returns
`void`
#### Source
[src/core/contracts/logging.ts:7](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/logging.ts#L7)
***
### warning()
> **warning**(`payload`): `void`
#### Parameters
**payload**: [`LogPayload`](/api/type-aliases/logpayload/)\<`T`\>
#### Returns
`void`
#### Source
[src/core/contracts/logging.ts:6](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/logging.ts#L6)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "MentionableSelectCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `MentionableSelectMenuInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:85](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L85)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`MentionableSelect`](/api/enumerations/commandtype/#mentionableselect)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:84](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L84)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "ModalSubmitCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `ModalSubmitInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:95](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L95)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Modal`](/api/enumerations/commandtype/#modal)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:94](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L94)

View File

@@ -0,0 +1,38 @@
---
editUrl: false
next: false
prev: false
title: "Plugin"
---
## Type parameters
**Args** *extends* `any`[] = `any`[]
## Properties
### execute()
> **execute**: (...`args`) => [`PluginResult`](/api/type-aliases/pluginresult/)
#### Parameters
• ...**args**: `Args`
#### Returns
[`PluginResult`](/api/type-aliases/pluginresult/)
#### Source
[src/types/core-plugin.ts:64](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L64)
***
### type
> **type**: [`PluginType`](/api/enumerations/plugintype/)
#### Source
[src/types/core-plugin.ts:63](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L63)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "RoleSelectCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `RoleSelectMenuInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:80](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L80)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`RoleSelect`](/api/enumerations/commandtype/#roleselect)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:79](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L79)

View File

@@ -0,0 +1,110 @@
---
editUrl: false
next: false
prev: false
title: "SernAutocompleteData"
---
## Extends
- `Omit`\<`BaseApplicationCommandOptionsData`, `"autocomplete"`\>
## Properties
### autocomplete
> **autocomplete**: `true`
#### Source
[src/types/core-modules.ts:172](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L172)
***
### command
> **command**: `AutocompleteCommand`
#### Source
[src/types/core-modules.ts:177](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L177)
***
### description
> **description**: `string`
#### Inherited from
`Omit.description`
#### Source
node\_modules/discord.js/typings/index.d.ts:4711
***
### descriptionLocalizations?
> `optional` **descriptionLocalizations**: `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`Omit.descriptionLocalizations`
#### Source
node\_modules/discord.js/typings/index.d.ts:4712
***
### name
> **name**: `string`
#### Inherited from
`Omit.name`
#### Source
node\_modules/discord.js/typings/index.d.ts:4709
***
### nameLocalizations?
> `optional` **nameLocalizations**: `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`Omit.nameLocalizations`
#### Source
node\_modules/discord.js/typings/index.d.ts:4710
***
### required?
> `optional` **required**: `boolean`
#### Inherited from
`Omit.required`
#### Source
node\_modules/discord.js/typings/index.d.ts:4713
***
### type
> **type**: `String` \| `Integer` \| `Number`
#### Source
[src/types/core-modules.ts:173](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L173)

View File

@@ -0,0 +1,106 @@
---
editUrl: false
next: false
prev: false
title: "SernEventCommand"
---
## Extends
- `Module`
## Type parameters
**T** *extends* keyof [`SernEventsMapping`](/api/interfaces/serneventsmapping/) = keyof [`SernEventsMapping`](/api/interfaces/serneventsmapping/)
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### name?
> `optional` **name**: `T`
#### Overrides
`Module.name`
#### Source
[src/types/core-modules.ts:42](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L42)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Sern`](/api/enumerations/eventtype/#sern)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:43](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L43)
## Methods
### execute()
> **execute**(...`args`): `unknown`
#### Parameters
• ...**args**: [`SernEventsMapping`](/api/interfaces/serneventsmapping/)\[`T`\]
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:44](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L44)

View File

@@ -0,0 +1,56 @@
---
editUrl: false
next: false
prev: false
title: "SernEventsMapping"
---
## Properties
### error
> **error**: [`object`]
#### Source
[src/types/utility.ts:21](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L21)
***
### module.activate
> **module.activate**: [[`Payload`](/api/type-aliases/payload/)]
#### Source
[src/types/utility.ts:20](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L20)
***
### module.register
> **module.register**: [[`Payload`](/api/type-aliases/payload/)]
#### Source
[src/types/utility.ts:19](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L19)
***
### modulesLoaded
> **modulesLoaded**: [`undefined?`]
#### Source
[src/types/utility.ts:23](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L23)
***
### warning
> **warning**: [[`Payload`](/api/type-aliases/payload/)]
#### Source
[src/types/utility.ts:22](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L22)

View File

@@ -0,0 +1,104 @@
---
editUrl: false
next: false
prev: false
title: "SernSubCommandData"
---
## Extends
- `APIApplicationCommandOptionBase`\<`ApplicationCommandOptionType.Subcommand`\>
## Properties
### description
> **description**: `string`
#### Inherited from
`APIApplicationCommandOptionBase.description`
#### Source
node\_modules/discord-api-types/payloads/v10/\_interactions/\_applicationCommands/\_chatInput/base.d.ts:7
***
### description\_localizations?
> `optional` **description\_localizations**: `null` \| `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`APIApplicationCommandOptionBase.description_localizations`
#### Source
node\_modules/discord-api-types/payloads/v10/\_interactions/\_applicationCommands/\_chatInput/base.d.ts:8
***
### name
> **name**: `string`
#### Inherited from
`APIApplicationCommandOptionBase.name`
#### Source
node\_modules/discord-api-types/payloads/v10/\_interactions/\_applicationCommands/\_chatInput/base.d.ts:5
***
### name\_localizations?
> `optional` **name\_localizations**: `null` \| `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`APIApplicationCommandOptionBase.name_localizations`
#### Source
node\_modules/discord-api-types/payloads/v10/\_interactions/\_applicationCommands/\_chatInput/base.d.ts:6
***
### options?
> `optional` **options**: [`SernOptionsData`](/api/type-aliases/sernoptionsdata/)[]
#### Source
[src/types/core-modules.ts:209](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L209)
***
### required?
> `optional` **required**: `boolean`
#### Inherited from
`APIApplicationCommandOptionBase.required`
#### Source
node\_modules/discord-api-types/payloads/v10/\_interactions/\_applicationCommands/\_chatInput/base.d.ts:9
***
### type
> **type**: `Subcommand`
#### Overrides
`APIApplicationCommandOptionBase.type`
#### Source
[src/types/core-modules.ts:208](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L208)

View File

@@ -0,0 +1,114 @@
---
editUrl: false
next: false
prev: false
title: "SernSubCommandGroupData"
---
## Extends
- `BaseApplicationCommandOptionsData`
## Properties
### autocomplete?
> `optional` **autocomplete**: `undefined`
#### Inherited from
`BaseApplicationCommandOptionsData.autocomplete`
#### Source
node\_modules/discord.js/typings/index.d.ts:4714
***
### description
> **description**: `string`
#### Inherited from
`BaseApplicationCommandOptionsData.description`
#### Source
node\_modules/discord.js/typings/index.d.ts:4711
***
### descriptionLocalizations?
> `optional` **descriptionLocalizations**: `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`BaseApplicationCommandOptionsData.descriptionLocalizations`
#### Source
node\_modules/discord.js/typings/index.d.ts:4712
***
### name
> **name**: `string`
#### Inherited from
`BaseApplicationCommandOptionsData.name`
#### Source
node\_modules/discord.js/typings/index.d.ts:4709
***
### nameLocalizations?
> `optional` **nameLocalizations**: `Partial`\<`Record`\<`"id"` \| `"en-US"` \| `"en-GB"` \| `"bg"` \| `"zh-CN"` \| `"zh-TW"` \| `"hr"` \| `"cs"` \| `"da"` \| `"nl"` \| `"fi"` \| `"fr"` \| `"de"` \| `"el"` \| `"hi"` \| `"hu"` \| `"it"` \| `"ja"` \| `"ko"` \| `"lt"` \| `"no"` \| `"pl"` \| `"pt-BR"` \| `"ro"` \| `"ru"` \| `"es-ES"` \| `"es-419"` \| `"sv-SE"` \| `"th"` \| `"tr"` \| `"uk"` \| `"vi"`, `null` \| `string`\>\>
#### Inherited from
`BaseApplicationCommandOptionsData.nameLocalizations`
#### Source
node\_modules/discord.js/typings/index.d.ts:4710
***
### options?
> `optional` **options**: [`SernSubCommandData`](/api/interfaces/sernsubcommanddata/)[]
#### Source
[src/types/core-modules.ts:214](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L214)
***
### required?
> `optional` **required**: `boolean`
#### Inherited from
`BaseApplicationCommandOptionsData.required`
#### Source
node\_modules/discord.js/typings/index.d.ts:4713
***
### type
> **type**: `SubcommandGroup`
#### Source
[src/types/core-modules.ts:213](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L213)

View File

@@ -0,0 +1,114 @@
---
editUrl: false
next: false
prev: false
title: "SlashCommand"
---
## Extends
- `Module`
## Properties
### description
> **description**: `string`
#### Overrides
`Module.description`
#### Source
[src/types/core-modules.ts:118](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L118)
***
### execute()
> **execute**: (`ctx`, `args`) => `unknown`
#### Parameters
**ctx**: [`Context`](/api/classes/context/)
**args**: [`"slash"`, [`SlashOptions`](/api/type-aliases/slashoptions/)]
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:120](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L120)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### options?
> `optional` **options**: [`SernOptionsData`](/api/type-aliases/sernoptionsdata/)[]
#### Source
[src/types/core-modules.ts:119](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L119)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Slash`](/api/enumerations/commandtype/#slash)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:117](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L117)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "StringSelectCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `StringSelectMenuInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:70](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L70)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`StringSelect`](/api/enumerations/commandtype/#stringselect)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:69](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L69)

View File

@@ -0,0 +1,114 @@
---
editUrl: false
next: false
prev: false
title: "TextCommand"
---
## Extends
- `Module`
## Properties
### alias?
> `optional` **alias**: `string`[]
#### Source
[src/types/core-modules.ts:112](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L112)
***
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`, `args`) => `unknown`
#### Parameters
**ctx**: [`Context`](/api/classes/context/)
**args**: [`"text"`, `string`[]]
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:113](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L113)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`Text`](/api/enumerations/commandtype/#text)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:111](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L111)

View File

@@ -0,0 +1,102 @@
---
editUrl: false
next: false
prev: false
title: "UserSelectCommand"
---
## Extends
- `Module`
## Properties
### description?
> `optional` **description**: `string`
#### Inherited from
`Module.description`
#### Source
[src/types/core-modules.ts:36](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L36)
***
### execute()
> **execute**: (`ctx`) => `unknown`
#### Parameters
**ctx**: `UserSelectMenuInteraction`\<`CacheType`\>
#### Returns
`unknown`
#### Overrides
`Module.execute`
#### Source
[src/types/core-modules.ts:90](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L90)
***
### name?
> `optional` **name**: `string`
#### Inherited from
`Module.name`
#### Source
[src/types/core-modules.ts:33](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L33)
***
### onEvent
> **onEvent**: [`ControlPlugin`](/api/interfaces/controlplugin/)\<`any`[]\>[]
#### Inherited from
`Module.onEvent`
#### Source
[src/types/core-modules.ts:34](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L34)
***
### plugins
> **plugins**: [`InitPlugin`](/api/interfaces/initplugin/)\<`any`[]\>[]
#### Inherited from
`Module.plugins`
#### Source
[src/types/core-modules.ts:35](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L35)
***
### type
> **type**: [`UserSelect`](/api/enumerations/commandtype/#userselect)
#### Overrides
`Module.type`
#### Source
[src/types/core-modules.ts:89](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L89)

View File

@@ -0,0 +1,74 @@
---
editUrl: false
next: false
prev: false
title: "Wrapper"
---
## Properties
### commands
> **commands**: `string`
#### Source
[src/types/core.ts:9](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core.ts#L9)
***
### containerConfig?
> `optional` **containerConfig**: `object`
#### get()
> **get**: (...`keys`) => `unknown`[]
##### Parameters
• ...**keys**: keyof `Dependencies`[]
##### Returns
`unknown`[]
#### Source
[src/types/core.ts:20](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core.ts#L20)
***
### defaultPrefix?
> `optional` **defaultPrefix**: `string`
#### Source
[src/types/core.ts:10](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core.ts#L10)
***
### events?
> `optional` **events**: `string`
#### Source
[src/types/core.ts:11](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core.ts#L11)
***
### ~~mode?~~
> `optional` **mode**: `string`
Overload to enable mode in case developer does not use a .env file.
:::caution[Deprecated]
- https://github.com/sern-handler/handler/pull/325
:::
#### Source
[src/types/core.ts:16](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core.ts#L16)

View File

@@ -0,0 +1,28 @@
---
editUrl: false
next: false
prev: false
title: "module"
---
> **module**\<`T`\>(`conf`): [`Config`](/api/namespaces/presence/type-aliases/config/)\<`T`\>
A small wrapper to provide type inference.
Create a Presence module which **MUST** be put in a file called presence.(language-extension)
adjacent to the file where **Sern.init** is CALLED.
## Type parameters
**T** *extends* keyof `Dependencies`[]
## Parameters
**conf**: [`Config`](/api/namespaces/presence/type-aliases/config/)\<`T`\>
## Returns
[`Config`](/api/namespaces/presence/type-aliases/config/)\<`T`\>
## Source
[src/core/presences.ts:28](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L28)

View File

@@ -0,0 +1,97 @@
---
editUrl: false
next: false
prev: false
title: "of"
---
> **of**(`root`): `object`
Create a Presence body which can be either:
- once, the presence is activated only once.
- repeated, per cycle or event, the presence can be changed.
## Parameters
**root**: `Omit`\<[`Result`](/api/namespaces/presence/interfaces/result/), `"repeat"` \| `"onRepeat"`\>
## Returns
`object`
### once()
> **once**: () => `Omit`\<[`Result`](/api/namespaces/presence/interfaces/result/), `"repeat"` \| `"onRepeat"`\>
#### Example
```ts
Presence
.of({
activities: [
{ name: "Chilling out" }
]
})
.once() // Sets the presence once, with what's provided in '.of()'
```
#### Returns
`Omit`\<[`Result`](/api/namespaces/presence/interfaces/result/), `"repeat"` \| `"onRepeat"`\>
### repeated()
> **repeated**: (`onRepeat`, `repeat`) => `object`
#### Example
```ts
Presence
.of({
activities: [{ name: "deez nuts" }]
}) //starts the presence with "deez nuts".
.repeated(prev => {
return {
afk: true,
activities: prev.activities?.map(s => ({ ...s, name: s.name+"s" }))
};
}, 10000)) //every 10 s, the callback sets the presence to the returned one.
```
#### Parameters
**onRepeat**: `PresenceReduce`
**repeat**: `number` \| [[`Emitter`](/api/interfaces/emitter/), `string`]
#### Returns
`object`
##### activities?
> `optional` **activities**: `ActivitiesOptions`[]
##### afk?
> `optional` **afk**: `boolean`
##### onRepeat
> **onRepeat**: `PresenceReduce`
##### repeat
> **repeat**: `number` \| [[`Emitter`](/api/interfaces/emitter/), `string`]
##### shardId?
> `optional` **shardId**: `number`[]
##### status?
> `optional` **status**: `Status`
## Source
[src/core/presences.ts:37](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L37)

View File

@@ -0,0 +1,74 @@
---
editUrl: false
next: false
prev: false
title: "Result"
---
## Properties
### activities?
> `optional` **activities**: `ActivitiesOptions`[]
#### Source
[src/core/presences.ts:11](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L11)
***
### afk?
> `optional` **afk**: `boolean`
#### Source
[src/core/presences.ts:10](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L10)
***
### onRepeat()?
> `optional` **onRepeat**: (`previous`) => [`Result`](/api/namespaces/presence/interfaces/result/)
#### Parameters
**previous**: [`Result`](/api/namespaces/presence/interfaces/result/)
#### Returns
[`Result`](/api/namespaces/presence/interfaces/result/)
#### Source
[src/core/presences.ts:14](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L14)
***
### repeat?
> `optional` **repeat**: `number` \| [[`Emitter`](/api/interfaces/emitter/), `string`]
#### Source
[src/core/presences.ts:13](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L13)
***
### shardId?
> `optional` **shardId**: `number`[]
#### Source
[src/core/presences.ts:12](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L12)
***
### status?
> `optional` **status**: `Status`
#### Source
[src/core/presences.ts:9](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L9)

View File

@@ -0,0 +1,34 @@
---
editUrl: false
next: false
prev: false
title: "Config"
---
> **Config**\<`T`\>: `object`
## Type parameters
**T** *extends* keyof `Dependencies`[]
## Type declaration
### execute()
> **execute**: (...`v`) => [`Result`](/api/namespaces/presence/interfaces/result/)
#### Parameters
• ...**v**: `IntoDependencies`\<`T`\>
#### Returns
[`Result`](/api/namespaces/presence/interfaces/result/)
### inject?
> `optional` **inject**: [`...T`]
## Source
[src/core/presences.ts:17](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/presences.ts#L17)

View File

@@ -0,0 +1,54 @@
---
editUrl: false
next: false
prev: false
title: "init"
---
`Experimental` `Alpha` `Beta`
> **init**(`maybeWrapper`): `void`
:::caution[Deprecated]
This is a test with typedoc
:::
:::caution[Experimental]
This API should not be used in production and may be trimmed from a public release.
:::
:::caution[Alpha]
This API should not be used in production and may be trimmed from a public release.
:::
:::caution[Beta]
This API should not be used in production and may be trimmed from a public release.
:::
## Parameters
**maybeWrapper**: [`Wrapper`](/api/interfaces/wrapper/) \| `"file"`
## Returns
`void`
## Since
1.0.0
## Example
```ts title="src/index.ts"
Sern.init({
commands: 'dist/commands',
events: 'dist/events',
})
```
This is a test with typedoc
This is a test with typedoc
This is a test with typedoc
## Source
[src/sern.ts:30](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/sern.ts#L30)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "AnyCommandPlugin"
---
> **AnyCommandPlugin**: [`ControlPlugin`](/api/interfaces/controlplugin/) \| [`InitPlugin`](/api/interfaces/initplugin/)\<[`InitArgs`\<`Processed`\<[`CommandModule`](/api/type-aliases/commandmodule/)\>\>]\>
## Source
[src/types/core-plugin.ts:76](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L76)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "AnyEventPlugin"
---
> **AnyEventPlugin**: [`ControlPlugin`](/api/interfaces/controlplugin/) \| [`InitPlugin`](/api/interfaces/initplugin/)\<[`InitArgs`\<`Processed`\<[`EventModule`](/api/type-aliases/eventmodule/)\>\>]\>
## Source
[src/types/core-plugin.ts:77](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L77)

View File

@@ -0,0 +1,22 @@
---
editUrl: false
next: false
prev: false
title: "Args"
---
> **Args**: `ParseType`\<`object`\>
## Type declaration
### slash
> **slash**: [`SlashOptions`](/api/type-aliases/slashoptions/)
### text
> **text**: `string`[]
## Source
[src/types/utility.ts:16](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L16)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "CommandModule"
---
> **CommandModule**: [`TextCommand`](/api/interfaces/textcommand/) \| [`SlashCommand`](/api/interfaces/slashcommand/) \| [`BothCommand`](/api/interfaces/bothcommand/) \| [`ContextMenuUser`](/api/interfaces/contextmenuuser/) \| [`ContextMenuMsg`](/api/interfaces/contextmenumsg/) \| [`ButtonCommand`](/api/interfaces/buttoncommand/) \| [`StringSelectCommand`](/api/interfaces/stringselectcommand/) \| [`MentionableSelectCommand`](/api/interfaces/mentionableselectcommand/) \| [`UserSelectCommand`](/api/interfaces/userselectcommand/) \| [`ChannelSelectCommand`](/api/interfaces/channelselectcommand/) \| [`RoleSelectCommand`](/api/interfaces/roleselectcommand/) \| [`ModalSubmitCommand`](/api/interfaces/modalsubmitcommand/)
## Source
[src/types/core-modules.ts:132](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L132)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "EventModule"
---
> **EventModule**: [`DiscordEventCommand`](/api/interfaces/discordeventcommand/) \| [`SernEventCommand`](/api/interfaces/serneventcommand/) \| [`ExternalEventCommand`](/api/interfaces/externaleventcommand/)
## Source
[src/types/core-modules.ts:131](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L131)

View File

@@ -0,0 +1,19 @@
---
editUrl: false
next: false
prev: false
title: "Initializable"
---
> **Initializable**\<`T`\>: `T`
Type to annotate that something is initializable.
If T has an init method, this will be called.
## Type parameters
**T** *extends* [`Init`](/api/interfaces/init/)
## Source
[src/types/ioc.ts:17](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L17)

View File

@@ -0,0 +1,22 @@
---
editUrl: false
next: false
prev: false
title: "LogPayload"
---
> **LogPayload**\<`T`\>: `object`
## Type parameters
**T** = `unknown`
## Type declaration
### message
> **message**: `T`
## Source
[src/core/contracts/logging.ts:11](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/contracts/logging.ts#L11)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "Payload"
---
> **Payload**: `object` \| `object` \| `object`
## Source
[src/types/utility.ts:26](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L26)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "PluginResult"
---
> **PluginResult**: `Awaitable`\<`VoidResult`\>
## Source
[src/types/core-plugin.ts:51](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-plugin.ts#L51)

View File

@@ -0,0 +1,14 @@
---
editUrl: false
next: false
prev: false
title: "SernOptionsData"
---
> **SernOptionsData**: [`SernSubCommandData`](/api/interfaces/sernsubcommanddata/) \| [`SernSubCommandGroupData`](/api/interfaces/sernsubcommandgroupdata/) \| `APIApplicationCommandBasicOption` \| [`SernAutocompleteData`](/api/interfaces/sernautocompletedata/)
Type that replaces autocomplete with [SernAutocompleteData](../../../../../../api/interfaces/sernautocompletedata)
## Source
[src/types/core-modules.ts:200](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/core-modules.ts#L200)

View File

@@ -0,0 +1,23 @@
---
editUrl: false
next: false
prev: false
title: "Singleton"
---
> **Singleton**\<`T`\>: () => `T`
Type to annotate that something is a singleton.
T is created once and lazily.
## Type parameters
**T**
## Returns
`T`
## Source
[src/types/ioc.ts:7](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L7)

View File

@@ -0,0 +1,12 @@
---
editUrl: false
next: false
prev: false
title: "SlashOptions"
---
> **SlashOptions**: `Omit`\<`CommandInteractionOptionResolver`, `"getMessage"` \| `"getFocused"`\>
## Source
[src/types/utility.ts:14](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/utility.ts#L14)

View File

@@ -0,0 +1,27 @@
---
editUrl: false
next: false
prev: false
title: "Transient"
---
> **Transient**\<`T`\>: () => () => `T`
Type to annotate that something is transient.
Every time this is called, a new object is created
## Type parameters
**T**
## Returns
`Function`
### Returns
`T`
## Source
[src/types/ioc.ts:12](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/types/ioc.ts#L12)

View File

@@ -0,0 +1,35 @@
---
editUrl: false
next: false
prev: false
title: "controller"
---
> `const` **controller**: `object`
## Since
1.0.0
The object passed into every plugin to control a command's behavior
## Type declaration
### next()
> **next**: () => `OkImpl`\<`void`\> = `ok`
#### Returns
`OkImpl`\<`void`\>
### stop()
> **stop**: () => `ErrImpl`\<`void`\> = `err`
#### Returns
`ErrImpl`\<`void`\>
## Source
[src/core/create-plugins.ts:69](https://github.com/sern-handler/handler/blob/91b3768e376cfe22ec37d8ab44f4e4a4dfe8a1e8/src/core/create-plugins.ts#L69)

View File

@@ -0,0 +1,86 @@
---
slug: blog/1.2.0
title: Release 1.2.0
authors: [jacoobes]
tags: [release]
date: 2022-09-28
---
## Class-based modules
Today we're announcing the ability to create class based modules!
To get started, install
```
npm install @sern/handler@latest
```
Quick List of changes!
- [Class-based modules](#class-based-modules-1)
- [Deprecation Warnings](#deprecation-warnings)
- [Dependencies Update](#dependencies-update)
### Class based modules
Incorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`
Extend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)
```ts title="commands/meaning-of-life.ts" {15}
import {
CommandType,
CommandExecutable,
type Args,
type Context,
} from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";
export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = "What is the meaning of life?";
override onEvent = [serendipityOnly()];
override plugins = [publish()];
execute = async (ctx: Context, args: Args) => {
await ctx.reply("42");
};
}
```
:::caution
execute must not be a method of the class. It should be as above, a property on the class!
:::
```ts title="events/guildMemberAdd.ts" {6}
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from "discord.js";
export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member);
};
}
```
Now, you might ask **why** this feature was added. <br /> Simply put, to give flexibility to the developers.
I believe that you should build your own structures however you might like and customize to your liking.
In addition, **decorators now unofficially work with modules!**
Feel free to use TypeScript experimental decorators to augment and customize your classes.
### Deprecation Warnings
The next update will bring sern v2 with some important features. Here are some things to watch out for.
- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated
- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated
- a SernEmitter will be automatically created once Sern#init is called
- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.
- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.
### Dependencies Update
- TypeScript has been updated to 4.8.3
- Discord.js has been upgraded to 14.5

View File

@@ -0,0 +1,68 @@
---
slug: blog/getting-started
title: How to get started with sern!
authors: [ethan]
tags: [guides]
date: 2022-09-30
---
## Hello everyone!
I'm Sr Izan, your fellow user and contributor.
Today I'm going to show you how to get started with sern and all its cool features.
### Step 1: Install the CLI.
Install the CLI:
```
npm i -g @sern/cli
```
and then run
```
sern init
```
:::tip
You can also run `sern init -y` if you want to use the default options.
:::
The CLI is written in Typescript and open-sourced on [Github](https://github.com/sern-handler/cli). (thanks [evo](https://github.com/EvolutionX-10)!)
### Step 2: Have some way to store secrets.
Normally you'd need a way to store secrets, and the best way to do that is by installing another package: `dotenv`
just `npm i dotenv` in the project folder and add `require('dotenv').config()` to your import section. Then, when you login, `process.env.TOKEN` (or however you have it named on your `.env` file) should do the trick.
:::caution
If you're using ESM, configure dotenv with `import 'dotenv/config'` instead of `require('dotenv').config()`.
:::
### And... that's it?
Yes, that's it. Here's a little FAQ to get you started. You can also join the [Discord](https://sern.dev/discord) for any problems.
### Extra: Video tutorial!
<video width="400" controls>
<source src="https://srizan.s-ul.eu/wtJBVsZU" type="video/mp4" />
</video>
## FAQ
**Q**: How do I publish a slash command?
**A**: Install the publish extension. Little video:
<video width="400" controls>
<source src="https://srizan.s-ul.eu/uHzPhfcS" type="video/mp4" />
</video>
**Q**: Any snippet VSCode extension?
**A**: Yeah, just search `sern Snippets` made by a verified publisher called Sr Izan (haha yeah me funny!)
**Q**: HEEEELLLPPPP!!!!
**A**: Hey, don't panic! We're here to help so, join the [Discord](https://sern.dev/discord). We're trying to get to 100 members!

View File

@@ -0,0 +1,217 @@
---
slug: blog/2.0.0
title: Release 2.0.0
authors: [jacoobes]
tags: [release]
date: 2022-12-13
---
## 2.0 Release
Join our [discord](https://sern.dev/discord)! <br />
Wow! We're finally increasing our semantic versioning by +`1.7.9.` <br />
What does this mean?
### Plugin Support for Event Modules
You can now use plugins for event modules. Previous version would throw an error if the
`plugins` field was populated.
```typescript
export function commandPlTest(): SernEmitterPlugin {
return {
type: PluginType.Command,
execute: ({ mod }, controller) => {
if (mod.name === "module.register") {
console.log("Event Module created correctly");
return controller.next();
}
console.log("event name is wrong");
return controller.stop();
},
};
}
```
Applying this plugin to some `eventModule`:
```typescript
export default eventModule({
name: "error",
type: EventType.Sern,
plugins: [commandPlTest()],
execute(m) {
console.log(m);
},
});
```
## Dependency Injection and Decoupling
The powerful npm package `iti` decouples sern even more.
Decoupling data structures with the Inversion of Control pattern separates data from logic, which will help speed production
and make sern even more customizable than before.
### How do I start?
```typescript title="src/index.ts"
//With typescript, you can customize / augment your typings.
interface MyDependencies extends Dependencies {
"@sern/client": Singleton<Client>;
"@sern/logger": Singleton<DefaultLogging>;
}
export const useContainer = Sern.makeDependencies<MyDependencies>({
// exclude: new Set(['@sern/logger']), don't autofill optional dependencies
build: (root) =>
root
.add({ "@sern/client": single(client) })
.add({ "@sern/logger": single(new DefaultLogging()) }),
});
Sern.init({
defaultPrefix: "!", // removing defaultPrefix will shut down text commands
commands: "src/commands",
// events: 'src/events' (optional),
containerConfig: {
get: useContainer, //pass in your dependency getter here
},
});
```
Using the `Sern#makeDependencies` function, inject your dependencies.
We'll use specific dependencies that are created with the `@sern/keyword`
key.
Using typescript to display all `keywords` and what they represent:
```typescript
export interface Dependencies {
"@sern/client": Singleton<EventEmitter>; //Discord Client
"@sern/logger"?: Singleton<Logging>; //Logger
"@sern/emitter": Singleton<SernEmitter>; //SernEmitter
"@sern/store": Singleton<ModuleStore>; //Stores all Command Modules
"@sern/modules": Singleton<ModuleManager>; //Manages Modules
"@sern/errors": Singleton<ErrorHandling>; //A Lifetime / Crash Handler
}
```
:::danger
Sern#addExternal has been deprecated and removed in favor of Sern#makeDependencies
:::
At the moment, one optional dependency, `@sern/logger`, exists. If not added explicitly,
we'll **autofill** with a [DefaultLogger](https://sern.dev/docs/api/classes/defaultlogging).
:::tip
If you don't want a logger, add it to the
`exclude` field while composing dependencies.
:::
Use your generated dependency getter `useContainer` (use whatever name you want), access them
from anywhere.
:::note
the function [useContainerRaw](https://sern.dev/docs/api/modules#usecontainerraw) is provided for direct access to dependencies and the internal
data structure. Use this wisely as no guarantees are made and crashes can happen.
:::
The `build` field follows [createContainer](https://itijs.org/docs/quick-start#usage) function call.
## New CommandTypes
2.0 includes all the new role select menus. `CommandType.MenuSelect` has been renamed into
`CommandType.StringSelect`. The remaining SelectMenus are
`CommandType.RoleSelect`, `CommandType.ChannelSelect`, `CommandType.UserSelect`, `CommandType.MentionableSelect`
```typescript title="commands/roleselect.ts"
export default commandModule({
type: CommandType.RoleSelect,
execute(ctx) {
ctx.reply("role select");
},
});
```
In addition, commandModules with ContextMenus have been renamed.
```diff
- CommandType.MenuUser, CommandType.MenuMsg
+ CommandType.CtxUser, CommandType.CtxMsg
```
## Typings Simplification
Pre 2.0:
<img src="https://cdn.discordapp.com/attachments/820348341358952550/1038577974829666386/image.png" />
<br/> <br/> <br/>
Post 2.0:
<br/>
<img src="https://cdn.discordapp.com/attachments/820348341358952550/1052623728489550015/image.png" />
CommandPlugin<T\> and EventPlugin<T\> typings have also been static'ified, transformed from types to interfaces
## Breaking Changes
<img src="https://img.srizan.dev/Discord_z8Sn1UBfEe.png" />
<br />
All deprecation warnings from previous versions have taken effect, and are removed in 2.0.
```diff lang="ts" showLineNumbers=false
- type Module = EventModule | CommandModule
+ type AnyModule = EventModule | CommandModule
-export type SpreadParams<T extends (...args: never) => unknown> = (
- args: Parameters<T>[number],
- ) => unknown;
```
Override type has been removed due to redundancy
```diff
- discord.js : 14.5
+ discord.js : 14.7
-typescript: 4.7
+ typescript: 4.9
```
```diff lang="ts" showLineNumbers=false
+ interface Wrapper {
+ readonly defaultPrefix?: string;
+ readonly commands: string;
+ readonly events?: string;
+ readonly containerConfig : {
+ get: (...keys: (keyof Dependencies)[]) => unknown[];
+ }
+}
- interface Wrapper {
- readonly client: Client;
- readonly sernEmitter?: SernEmitter;
- readonly defaultPrefix?: string;
- readonly commands: string;
- readonly events?:
- | string
- | { mod: EventModule; absPath: string }[]
- | (() => { mod: EventModule; absPath: string }[]);
-}
```
```diff lang="ts" showLineNumbers=false
+ DefaultLogger
+ DefaultModuleManager
+ SernEmitter
+ DefaultErrorHandling
+ type Singleton<T> = () => T
+ type Transient<T> = () => () => T;
+ type LogPayload<T = unknown> = { message: T }
+ export const single = <T>() => T
+ export const many = <T>() => () => T
```
Including the previous section, some names to symbols and data structures were altered to
be better represented. view [changelog](/404.html)
## Context refactoring
The context data structure has been internally altered to represent its dynamics better.

View File

@@ -0,0 +1,38 @@
---
slug: blog/2.5.0
title: Release 2.5.0
authors: [jacoobes]
tags: [release]
date: 2023-01-12
---
## 2.5 Release
### Join our [discord](https://sern.dev/discord) <br />
- Thank you for using sern in your projects. It's only going to get better!
- I apologize for the sudden small breaking change. After this update, there won't be any for a while.
Wow! We're increasing our semantic versioning by `+0.3.9` <br />
What does this mean?
### Breaking changes
- [controller](../docs/api/modules#controller) parameter for plugins has been removed
- You'll need to import it instead
- This **breaks** old [CommandPlugin](../docs/api/interfaces/CommandPlugin), but **not** old [EventPlugin](../docs/api/interfaces/EventPlugin)
### Deprecations
- [CommandPlugin](../docs/api/interfaces/CommandPlugin) and [EventPlugin](../docs/api/interfaces/EventPlugin) have been renamed [InitPlugin](../docs/api/interfaces/InitPlugin) and [ControlPlugin](../docs/api/interfaces/ControlPlugin)
### Reason
- The naming of plugins was getting too complex. For example, plugin naming evolved into CommandModuleCommandPlugin, CommandModuleEventPlugin and more.
- I realize that this affects all plugins. I have updated all [plugins](https://github.com/sern-handler/awesome-plugins/pull/68) to match these changes
- The old way of declaring plugins has been deprecated in favor of newer functions that facilitate and ease typings
- [CommandControlPlugin](../docs/api/modules#commandcontrolplugin)
- [CommandInitPlugin](../docs/api/modules#commandinitplugin)
- [EventControlPlugin](../docs/api/modules#eventcontrolplugin)
- [EventInitPlugin](../docs/api/modules#eventinitplugin)
- [DiscordEventControlPlugin](../docs/api/modules#discordeventcontrolplugin)
This will probably be the last breaking change in a while. Thanks for using sern!

View File

@@ -0,0 +1,109 @@
---
slug: blog/3.0.0
title: Release 3.0.0
authors: [jacoobes]
tags: [release]
date: 2023-06-18
---
## 3.0 Release
### Join our [discord](https://sern.dev/discord) <br />
### Features
#### Dependency Management
- `Service` API (recommended to use this over useContainer hooks)
- Dependencies type must be globally augmented in order for Services api to function properly
- new methods on ModuleManager
- getPublishableCommands()
- Init Hooks
- implement starting behavior for dependencies
- To enforce and type check this, use the `Initializable` type when making your Dependencies type!
- Emitter interface
- More generic interface to define any event emitter
- You can now swap out the SernEmitter with whatever emitter now.
```ts
class DatabaseService implements Init {
//some hypothetical database
_pgsql : database()
async init() {
await _pgsql.load()
}
}
await makeDependencies({
build: root => root.add({
db: new DatabaseService() //will be init'ed automatically
})
})
```
- new SernEmitter event `modulesLoaded` , which allows users to customize behavior after all modules are loaded!
```ts
export default eventModule({
name: "modulesLoaded",
type: EventType.Sern,
execute: () => {
console.log("All modules loaded");
},
});
```
#### Quality of Life
- faster module loading
- I utilize async generators for reading files now. A lot faster than the first iteration.
- better error handling
- Less boilerplate
- Services api cleans up v2 boilerplate
- class modules devex got upgraded and work better than before
- automatically ignore any files not ending in (mts, cts, mjs, cjs, ts, js)
- ignore commands and events with `!` prefix on filename or directory (ie: `!filename.ts` or `!directory` will be ignored by sern)
- `Service` API (recommended to use this over useContainer hooks)
- Dependencies type must be globally augmented in order for Services api to function properly
- Less boilerplate
- new methods on ModuleManager
- automatically ignore any files not ending in (mts, cts, mjs, cjs, ts, js)
- ignore commands / events with `!` prefix on filename or directory (ie: `!filename.ts` or `!directory`)
- new SernEmitter event `modulesLoaded` , which allows users to customize behavior after all modules are loaded!
- Init Hooks
- implement starting behavior for dependencies
### Experimental
- Experimental things may be subject to removal, need feedback and are not guaranteed stable
- dev / prod mode
- sern will behave differently depending on mode set
- init sern from `file` option
- reads from local sern.config.json
```js
Sern.init("file");
```
### Breaking changes
- Sern.makeDependencies -> makeDependencies
- it is asynchronous and top level function now. Make sure to await it before initing for proper synchronization.
- module store and manager internally changed, so those using them may recieve breaking changes
- BaseOptions type removed
```diff lang="ts" showLineNumbers=false
- Sern.makeDependencies({ build: () => {} })
+ await makeDependencies({ build: () => {} })
```
### Deprecations
- Removed all previous marked deprecations in v3
- ModuleStore will be removed as a dependency in v4. The only way to access modules should be through ModuleManager
- Default Dependencies will be made internal in the v4. Users should only have access to its interface / contract

View File

@@ -0,0 +1,35 @@
---
slug: blog/new-logo
title: New logo!
authors: [sern]
tags: [branding]
date: 2023-07-04
---
Hey everyone! Today we have very special news for you all: We're changing our logo!
# Why?
You see, on today's standards, having a simple logo is essential. Our logo aligns perfectly with these design principles but it can always be improved.
We were chilling, you know, cooking sern handler v3, sern gui, `npm create @sern/bot` and serncord when we thought about changing the logo to a sleek design with less colors.
And here we are!
# Who did our new branding?
[Ropox](https://github.com/Murtatrxx)!
Bro's the GOAT. This website is maintained by him, the domain costs are funded by him and also he started brainstorming how the logo would be on paper:
![](/src/assets/blog/paper-prototypes.jpg)
And there it all clicked:
![](/src/assets/blog/paper-logo.png)
seren tried by the way!
![](/src/assets/blog/seren-tried.png)
# Anyways, here it is:
![](/img/logo.png)
Pretty nice!
By the way, we have animations and variations on the way, so make sure to stay updated in the [discord server](https://sern.dev/discord)!
# Finally, from the entire sern team, thank you for sticking around ❤️

View File

@@ -0,0 +1,37 @@
---
slug: blog/railway-deploy
title: Deploying sern with Railway
authors: [duro]
tags: [guides]
date: 2024-02-23
---
In this guide, I'll be showing you how to deploy your sern bot with [Railway](https://railway.app/).
This guide assumes you have a sern bot already set up and ready to deploy. If you don't, you can follow the [Getting Started](/blog/getting-started) guide to set up your bot.
## GitHub Repository
The first thing you'll need to deploy your bot is a GitHub repository for your bot. If you don't have one, you can create one by following the [GitHub guide](https://docs.github.com/en/get-started/quickstart/create-a-repo).
Once you have your repository set up, you can push your bot's code to the repository, and you're ready to deploy using Railway.
## Railway Setup
After you have your bot's code in a GitHub repository, you'll need to create an account on Railway. You can sign up using your GitHub account at [railway.app](https://railway.app/).
Once you've created your account, navigate to the [dashboard](https://railway.app/dashboard) and click the "New Project" button. Click the "Deploy from GitHub repo" button, and select your bot's repository.
Once you've selected your repository, click the "Add Variables" button to add your bot's environment variables. You'll need your environment variables from your `.env` file to add to Railway. (You can also add these later if you want.)
## Deploy
Once you've added your environment variables, click the "Deploy" button, and Railway will start deploying your bot. Once the deployment is complete, you'll be able to see your bot's URL and logs.
:::note
Make sure you add your environment variables, and your node start script is correct in your `package.json` file.
If you have any issues deploying your bot, you can check the logs for any errors.
:::
That's it! Your bot is now deployed and running on Railway. If you have any issues or questions, feel free to ask in the [sern Discord server](https://sern.dev/discord).

View File

@@ -0,0 +1,34 @@
---
title: About the CLI
---
Publish commands to the API, install plugins, and use other tools provided by our cli.
The CLI is your pocketknife for discord bot development. It'll have all features necessary for developing and shipping to production.
```ansi
Usage: sern [options] [command]
___ ___ _ __ _ __
/ __|/ _ \ '__| '_ \
\__ \ __/ | | | | |
|___/\___|_| |_| |_|
Welcome!
If you're new to sern, run npm create @sern/bot for an interactive setup to your new bot project!
If you have any ideas, suggestions, bug reports, kindly join our support server: https://sern.dev/discord
Options:
-v, --version output the version number
-h, --help display help for command
Commands:
init [options] Quickest way to scaffold a new project [DEPRECATED]
plugins [options] Install plugins from https://github.com/sern-handler/awesome-plugins
extra Easy way to add extra things in your sern project
commands Defacto way to manage your slash commands
help [command] display help for command
```

View File

@@ -0,0 +1,215 @@
---
title: Build
---
```sh
Usage: sern build [options]
Build your bot
Options:
-f --format [fmt] The module system of your application. `cjs` or `esm` (default: "esm")
-m --mode [mode] the mode for sern to build in. `production` or `development` (default: "development")
-W --suppress-warnings suppress experimental warning
-p --project [filePath] build with this sern.build file
-h, --help display help for command
```
## Guiding Principles
When designing the `sern build` command, our aim was to make building bot applications as simple as possible for the majority of developers. The setup process has been streamlined, and most of the configuration details have been handled for you. Here are some key points to keep in mind:
1. **Minimal Configuration**: In the vast majority (99%) of use cases, developers do not need to configure the bot application building process. We believe that simplicity is key, so only a few decisions need to be made on the developer's end.
2. **Optimal Defaults**: We've chosen sensible defaults. This means you can get started without getting bogged down by complex, unneeded configurations.
3. **Finetuned for production bots**: Our CLI leverages an opinionated build solution powered by esbuild. This ensures that bots are built without issues and can be shipped easily.
## Experimental Features
Both the `sern build` and `sern publish` commands are marked as experimental. While they might not be completely stable, they are designed to work for the majority of users. We appreciate any feedback in helping us make these features even better.
## Features
The `sern build` command comes equipped with a range of features designed to enhance your development process. Here's a glimpse of what it offers:
- **esbuild Integration**: our CLI takes inspiration from the efficiency of SvelteKit, ensuring your bot application is built effectively and with type safety. Leverage the [esbuild plugin ecosystem](https://github.com/esbuild/community-plugins).
- **Zero Configuration**: Building your bot application without additional configuration. The CLI handles most of the setup for you.
- **Experimental Image Support**: We've introduced experimental support for top-level imports of PNG and JPG files, making it easier to include images in your bot application.
- **Compile Time Constants**: Customize your build with constants such as `__DEV__`, `__PROD__`, allowing you to tailor your application to different production stages.
- **Development and Production Modes**: The CLI supports both development and production modes, enabling you to tailor your bot application for different stages of development.
- **Type-safe `process.env`**: The CLI generates a type-safe `process.env`, reducing potential errors.
## Implicits
- command line arguments take precendence over sern.build configuration file
- default build format is ESM
- defineVersion = true
- **DEV** AND **PROD** constants are configured.
- only a [few tsconfig options](https://esbuild.github.io/content-types/#tsconfig-json) are respected.
### sern.build.js
- For any extra configuration you may need
- the cli was intentionally made to be installed globally, and we can't provide typings at a project level. If you need typings, here they are:
```ts
type BuildOptions = {
/**
* Define __VERSION__
* This option is a quick switch to defining the __VERSION__ constant which will be a string of the version provided in
* cwd's package.json
*/
defineVersion?: boolean;
/**
* default = esm
*/
format?: "cjs" | "esm";
/**
* extra esbuild plugins to build with sern.
*/
esbuildPlugins?: esbuild.Plugin[];
/**
* https://esbuild.github.io/api/#drop-labels
**/
dropLabels?: string[];
/**
* https://esbuild.github.io/api/#define
**/
define?: Record<string, string>;
/**
* Path to tsconfig
**/
tsconfig?: string;
/**
* default = 'development'
*/
mode: "production" | "development";
/**
* will search for env file. If none exists,
* default to .env.
*/
env?: string;
};
```
## Usage
```
sern build
```
(that was easy)
## Adapting older projects
- Change your tsconfig.json to extend our generated one.
```json {2}
{
"extends": "./.sern/tsconfig.json",
"compilerOptions": {
// all of your old fields
}
}
```
## In depth
We use the `define` and `drop labels` api in C style macros to have easy development stage differences.
[Here](https://esbuild.github.io/api/#drop-labels) is the esbuild full API documentation
### drop labels
```sh
# mode is set to production
sern build
```
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs>
<TabItem value="input" label="Input">
```ts
__DEV__: console.log("This is for production only");
__PROD__: console.log("This is for either mode");
```
</TabItem>
<TabItem value="sh" label="Running build for production">
```sh
# mode is set to production
sern build
```
</TabItem>
<TabItem value="output" label="Output">
```ts
__PROD__ console.log('This is for either mode')
```
</TabItem>
</Tabs>
### constants
sern builds with three default constants. `__DEV__`, `__PROD__`, `__VERSION__`.
<Tabs>
<TabItem value="input" label="Preprocess">
```sh
sern build
```
</TabItem>
<TabItem value="sh" label="Constants available and typesafe!">
```ts
if (__PROD__) {
console.log("Bot version: " + __VERSION__);
}
```
</TabItem>
</Tabs>
Full esbuild documentation [here](https://esbuild.github.io/api/#define)
Add more to the `define` field in build options (only availible with a `sern.build` file at the moment.
### process.env
We generate your process.env with `dotenv` and generate typings for process.env. Less hassle!
<Tabs>
<TabItem value="input" label=".env">
```sh frame="none"
DISCORD_TOKEN=<your token>
```
```ts
process.env.DISCORD_TOKEN; // string | undefined (not typesafe :()
```
</TabItem>
<TabItem value="sh" label="sern build">
```sh
sern build
```
```ts
process.env.DISCORD_TOKEN; // string (typesafe :))
```
</TabItem>
</Tabs>

View File

@@ -0,0 +1,35 @@
---
title: Clear
---
```sh
Usage: sern commands clear [options]
Clear and reset commands-data-remote.json and the api
Options:
-y, --yes Say yes to all prompts
-e, --env [path] Supply a path to a .env
-h, --help display help for command
```
## Implicits
- Automatically reads a .env in the working directory. For seamless integration, your .env file should look like this:
```sh title=".env"
DISCORD_TOKEN=<YOUR_TOKEN>
APPLICATION_ID=<YOUR_APPLICATION_ID>
NODE_ENV=<development|production>
```
- Calls the discord API with the [PUT route](https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands) with an EMPTY array, essentially setting all registered commands to nothing.
- Optionally override an .env path as a command line argument as well. **CLI arguments take precedence.**
If you do not know how to obtain either of these credentials, [click here](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)
- Automatically confirm with the **-y** flag.
## Features
- Clears all application data and sern-commands-data.json

View File

@@ -0,0 +1,14 @@
---
title: Extra
---
```sh
Usage: sern extra [options]
Easy way to add extra things in your sern project
Options:
-h, --help display help for command
```
This command is pretty straightfoward. Install utilities into your application. Assumes you have a sern.config.json.

View File

@@ -0,0 +1,117 @@
---
title: Publish
---
```sh
Usage: sern commands publish [options] [path]
New way to manage your slash commands
Arguments:
path path with respect to current working directory that will locate all published files
Options:
-i, --import [scriptPath...] Prerequire a script to load into publisher
-t, --token [token]
--appId [applicationId]
-h, --help display help for command
```
## Implicits
- Automatically reads a .env in the working directory. For seamless integration, your .env file should look like this:
```sh title=".env"
DISCORD_TOKEN=<YOUR_TOKEN>
APPLICATION_ID=<YOUR_APPLICATION_ID>
NODE_ENV=<production|development>
```
- Calls the discord API with the [PUT route](https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands). Wherever your commands directory is located, publish will override the existing application commands at Discord. Existing commands do not count towards the command limit creation daily.
You may pass these in as command line arguments as well. **CLI arguments take precedence.**
If you do not know how to obtain either of these credentials, [click here](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)
## Usage
![usage](/src/assets/docs/sern-publish.gif)
## Features
- Automatically syncs api with your command base
- generates JSON file of output (**.sern/command-data-remote.json**)
- supports publishing direct esm typescript files
- commonjs + javascript users need to compile first and then run sern publish on the dist/ output
- prerequire scripts.
- supports a configuration that is the same as the original publish plugin.
Each command file can have an extra config that follows `ValidPublishOptions`:
## Config
```ts
type ValidMemberPermissions =
| PermissionFlagBits //discord.js enum
| PermissionFlagBits[] //array of discord.js enum
| string //must be a stringified number
| bigint
interface PublishConfig {
guildIds?: string[];
dmPermission?: boolean;
defaultMemberPermissions: ValidMemberPermissions;
}
type ValidPublishOptions =
| PublishConfig
| (absPath: string, module: CommandModule) => PublishConfig
```
In other words, you can export a function or object.
## Prerequiring
Is there a [service](../guide/walkthrough/services) that is required at the top level of a command?
- Create an ES6 script anywhere:
```ts title="scripts/prerequire.mjs"
import { makeDependencies, single, Service } from "@sern/handler";
import { Client } from "discord.js";
await makeDependencies({
build: (root) =>
root.add({ "@sern/client": single(() => new Client(...options)) }),
});
await Service("@sern/client").login();
```
This will create a container for publishing. (as of 0.6.0, client is required or this will crash)
### Example: command published in guild
#### Script ran:
```
sern commands publish -i ./scripts/prerequire.mjs
```
```ts title=src/commands/ping.ts
import { commandModule, Service, CommandType } from '@sern/handler'
const client = Service('@sern/client');
export const config = {
guildIds: ["889026545715400705"]
}
export default commandModule( {
type: CommandType.Slash
description: `${client.user.username}'s ping`,
execute: (ctx) => {
ctx.reply('pong')
}
})
```

View File

@@ -0,0 +1,12 @@
---
title: Choosing an IDE
---
Choosing an IDE is a matter of personal preference. They make programming easier. The following are some
suggestions for choosing an IDE:
- [Visual Studio Code](https://code.visualstudio.com)
- we have an [snippet extension](https://marketplace.visualstudio.com/items?itemName=SrIzan.sern-snippets) to help automate development :)
- [Sublime Text](https://www.sublimetext.com/)
- [NotePad++](https://notepad-plus-plus.org/)
- [nvim](https://neovim.io/) (chad)

View File

@@ -0,0 +1,13 @@
---
title: Preparing to Code
---
After installing an IDE, you need to install node.
[Click to download the LTS version of node right here](https://nodejs.org/en/download/).
After you downloaded node you will need:
#### [Discord token](https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token)
CONTINUE 🤓

View File

@@ -0,0 +1,44 @@
---
title: Autocomplete
sidebar:
order: 9
---
Autocomplete is a special interaction where it can happen on multiple options on a single command. We've handled this with a simple
tree search algorithm in a nested options tree.
## Example
```ts title="src/commands/cheese.ts" {13-21}
export default commandModule({
type: CommandType.Slash,
description: "show me cheese",
options: [
{
name: "list",
type: ApplicationCommandOptionType.String,
description: "pick a cheese to show",
required: true,
autocomplete: true,
command: {
onEvent: [],
execute: (ctx) => {
const focus = ctx.options.getFocused();
ctx.respond(
["gouda", "parmesan", "harvati"].map((cheese) => ({
name: cheese,
value: cheese,
})),
);
},
},
},
],
execute: (ctx, [, args]) => {
const cheese = args.getString("list", true);
ctx.reply("selected cheese");
},
});
```
Sern will handle autocomplete interactions at arbitrary depths and subcommand levels.

View File

@@ -0,0 +1,37 @@
---
title: CLI
sidebar:
order: 3
---
Setting up the [CLI](https://github.com/sern-handler/cli) is easy.
The cli is your plug to the sern ecosystem. This will allow you to install plugins with ease, install extra utilities, and much more.
If you haven't yet:
```sh
npm install -g @sern/cli
```
- To install [plugins](plugins.md) maintained by the community [repository](https://github.com/sern-handler/awesome-plugins),
```sh
sern plugins
```
:::caution
Make sure to have a correct [sern.config.json](./good-to-know.md#sernconfigjson)
:::
This will display a menu selection of all installable plugins.
**Note**: You must have a [sern.config.json](good-to-know.md) to use this command.
If you want to view plugins, visit the repository linked above.
- To install extra utilities into your project
```sh
sern extra
```
We have a more in depth [guide](../../cli/README.md) of the CLI

View File

@@ -0,0 +1,11 @@
---
title: Conclusion
sidebar:
order: 12
---
If you reached this far, thank you for reading! We hope you have learned the necessities you need
to create a bot with the sern framework. If you have any other questions, bugs, feature requests, concerns, please join our
[community server](https://sern.dev/discord), and we'll be glad to answer your questions.
![](/blog/newlogo/paperlogo.png)

View File

@@ -0,0 +1,113 @@
---
title: Dependency Injection
sidebar:
order: 10
---
:::caution
This contains version 2 code. Please view [transitioning to v3](./transition)
:::
Since version 2.0.0, dependency injection, thanks to [iti](https://github.com/molszanski/iti), is a feature to customize your bot's utilities and structures.
Minimal setup for any project.
```ts
const client = new Client({
...options,
});
Sern.makeDependencies<MyDependencies>({
build: (root) =>
root.add({
"@sern/client": single(() => client),
}),
});
```
For any typescript project, you'll need to add an interface to get intellisense and typings.
```typescript
interface MyDependencies extends Dependencies {
"@sern/client": Singleton<Client>;
}
```
Full Dependency Injection setup
```typescript
const client = new Client({
...options,
});
interface MyDependencies extends Dependencies {
"@sern/client": Singleton<Client>;
}
export const useContainer = Sern.makeDependencies<MyDependencies>({
build: (root) =>
root.add({
"@sern/client": single(() => client),
}),
});
```
Everything else is handled. However, you may want customize things.
## Adding dependencies to root
Each sern built dependency must implement its contracts.
- `@sern/logger`: Log data. [Logging](../../api/interfaces/Logging)
- `@sern/errors`: Handling errors and lifetime. [ErrorHandling](../../api/interfaces/ErrorHandling)
- `@sern/modules`: Managing all command modules. [ModuleManager](../../api/interfaces/ModuleManager)
- `@sern/emitter`: is the key to emit events and occurences in a project. [SernEmitter](../../api/classes/SernEmitter)
You may also add disposers so that when the application crashes, the targeted dependency calls that function.
```typescript
export const useContainer = Sern.makeDependencies<MyDependencies>({
build: (root) =>
root
.add({
"@sern/client": single(() => client),
})
.addDisposer({ "@sern/client": (client) => client.destroy() }),
});
```
:::tip
Below is v3 api.
:::
## Init
Do you need to perform intializing behavor for a dependency?
```ts
import { Init } from "@sern/handler";
class Database implements Init {
init() {
await this.connect();
console.log("Connected");
}
}
```
Modify you Dependencies interface:
```ts title="src/dependencies.d.ts"
import type { Initializable } from "@sern/handler";
interface Dependencies extends CoreDependencies {
database: Initializable<Database>;
}
```
Make sure its been added:
```ts title="src/index.ts"
await makeDependencies({
build: root => root
.add({ database => new Database() })
})
```

View File

@@ -0,0 +1,110 @@
---
title: First Command
sidebar:
order: 5
---
We will dissect a basic command.
If you installed a new project via the cli, This is the `ping` command located in src/commands folder.
:::tip
TLDR: command modules are discord bot commands. There are many types, and each one will correspond to an event from discord.
For example, CommandType.Slash commands will listen to slash command interactions.
:::
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs syncKey="language-preference">
<TabItem value="js" label="JavaScript">
```js
const { CommandType, commandModule } = require("@sern/handler");
export default commandModule({
type: CommandType.Both,
plugins: [],
description: "A ping command",
// alias : [],
execute: async (ctx, args) => {
await ctx.reply("Pong 🏓");
},
});
```
</TabItem>
<TabItem value="ts" label="Typescript">
```ts
import { commandModule, CommandType } from "@sern/handler";
export default commandModule({
type: CommandType.Both,
plugins: [],
description: "A ping command",
// alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: "Pong 🏓" });
},
});
```
</TabItem>
</Tabs>
To view what each of these properties mean in depth, visit the [official documentation](https://sern.dev/docs/api/enums/CommandType).
### Types of command modules
Every command module `type` is part of an enum. This field allows type inference for the rest of a module's fields. <br />
All the command types can be found in the [official documentation](https://sern.dev/docs/api/enums/CommandType)!
<p>So, lets say you want to make a command module that listens to modals. </p>
**Note**: Keep in mind you'll need to send a modal with a custom id `dm-me`. This example below is the response to a modal being sent.
<br />
<Tabs syncKey="language-preference">
<TabItem value="js" label="JavaScript">
```javascript
const { CommandType, commandModule } = require("@sern/handler");
exports.default = commandModule({
name: "dm-me",
type: CommandType.Modal,
async execute(modal) {
const value = modal.fields.getTextInputValue("message");
modal.client.users
.fetch("182326315813306368")
.then((u) => u.send(value + ` from ${modal.user}`));
modal.reply({ ephemeral: true, content: "Sent" });
},
});
```
</TabItem>
<TabItem value="ts" label="Typescript">
```typescript
import { commandModule, CommandType } from "@sern/handler";
export default commandModule({
name: "dm-me",
type: CommandType.Modal,
async execute(modal) {
const value = modal.fields.getTextInputValue("message");
modal.client.users
.fetch("182326315813306368")
.then((u) => u.send(value + ` from ${modal.user}`));
modal.reply({ ephemeral: true, content: "Sent" });
},
});
```
</TabItem>
</Tabs>
Commands are straight forward. Keep in mind, every other property on the commandModule object is
optional **except** the type and execute function.
# Context class
The provided Context class helps with modules of `CommandType.Both` (A mixture of slash / legacy commands).
The Context class is passed into modules with type:
- `CommandType.Both`
- `CommandType.Slash`
- `CommandType.Text`
This data structure helps interop between legacy commands and slash commands with ease.

View File

@@ -0,0 +1,69 @@
---
title: First Event
sidebar:
order: 6
---
We will dissect a basic event module. <br />
:::tip
TLDR: event modules are event listeners. there are three types EventType.Discord, EventType.Sern, EventType.External
:::
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs syncKey="language-preference">
<TabItem value="js" label="JavaScript">
```javascript
exports.default = eventModule({
type: EventType.Sern,
plugins : [],
name: 'module.activate',
execute(event) {
console.log(event);
}
})
```
</TabItem>
<TabItem value="ts" label="Typescript">
```typescript
export default eventModule({
type: EventType.Sern,
plugins : [],
name: 'module.activate', //name of event.
execute(event) {
console.log(event);
}
})
```
</TabItem>
</Tabs>
Like command modules, the `type` property denotes what kind of event it is, which
can be found [here](https://sern.dev/docs/api/enums/EventType).
To view what each of these properties mean in depth, visit the [official documentation](https://sern.dev/docs/api/enums/EventType).
## External
In version 2 & 3, any dependency that you have passed into makeDependencies can be registered here as well.
```ts title="src/index.ts"
await makeDependencies({
build: root => root.add({
eventlistener: single(() => new EventEmitter())
})
})
```
```ts title="events/myevent.ts"
export default eventModule({
type: EventType.External,
emitter: 'eventlistener',
execute: (args) => {
console.log('Got event from eventlistener: ', args);
}
})
```

View File

@@ -0,0 +1,52 @@
---
title: Goal
sidebar:
order: 1
---
This walkthrough will be written in [TypeScript](https://www.typescriptlang.org/) but will have JavaScript snippets throughout.
# Make robust, modular, bots
- _Modularity_: sern is built with modularity in mind. You can swap pieces and parts easily.
- _Familiar_: commands and structures are similar to classic v12 handlers and the official discord.js command handler guide, while packing many features
- _Concise_: Too much code is a liability. with sern, write less for more 🤯
### Using @sapphire/framework
```ts title="commands/ping.ts" showLineNumbers
import { Command } from "@sapphire/framework";
import type { CommandInteraction } from "discord.js";
export class PingCommand extends Command {
public constructor(context: Command.Context) {
super(context, {
description: "Pong!",
chatInputCommand: {
register: true,
},
});
}
public async chatInputRun(interaction: CommandInteraction) {
await interaction.reply("Pong!");
}
}
```
### Using @sern/handler
```ts title="commands/ping.ts" showLineNumbers
import { commandModule, CommandType } from "@sern/handler";
import { publish } from "../plugins";
export default commandModule({
type: CommandType.Both,
plugins: [publish()],
description: "Pong!",
execute: (ctx, args) => {
await ctx.reply("Pong!");
},
});
```
Keep in mind the above example acts as both a slash command AND text command

View File

@@ -0,0 +1,25 @@
---
title: Good to Know
sidebar:
order: 13
---
## sern.config.json
<p>A sern.config.json, although not necessary, allows your project to communicate with our cli.</p>
For example, when installing typescript plugins, the language property is necessary to install from our
[open source repository](https://github.com/sern-handler/awesome-plugins). <br />
Using the cli and running `sern init --sync` on pre-existing projects should install this json file in the root directory given.
Or, if this is a brand-new project, `sern init` automatically installs it.
```json
{
"language": "typescript",
"paths": {
"base": "src",
"commands": "commands"
}
}
```

View File

@@ -0,0 +1,13 @@
---
title: New Project
sidebar:
order: 2
---
```sh
npm create @sern/bot
```
and follow the interactive prompts.
if somehow you need help, feel free to ask [here](https://sern.dev/discord)

View File

@@ -0,0 +1,101 @@
---
title: Plugins
sidebar:
order: 7
---
:::tip
TLDR: Plugins help reduce code repetition and are installable via `sern plugins`. Put them onto the plugins field of a command/event module.
:::
## Installing
Chances are, you just want your bot to work. Plugins can preprocess and create reusable conditions for modules.
run:
```sh
sern plugins
```
- Install your favorite(s) (or the ones that look the coolest). In my imaginary mind, I installed the ownerOnly plugin.
- This should install in `plugins` directory in `src`.
- Some plugins only work with specific types. Most are targeted towards slash / both modules.
- Add to your module.
```ts
import { commandModule, CommandType } from '@sern/handler'
import { ownerOnly } from '../plugins'
export default commandModule({
type: CommandType.Both,
plugins: [ownerOnly(['182326315813306368')],
description: 'ping command',
execute: (ctx) => {
ctx.reply('hello, owner');
}
})
```
#### ┗| O|┛ perfect, your first plugin!
## Creating your own plugins
The controller determines in plugins whether to continue or fail.
### The controller object
```typescript
export interface Controller {
next: () => Ok<void>;
stop: () => Err<void>;
}
```
## Init Plugins
Init plugins modify how commands are loaded or do preprocessing.
An instance of the above object is passed into every plugin. <br />
This controls whether a module is stored into sern. <br />
```typescript
import { CommandInitPlugin } from "@sern/handler";
import path from "path";
export const inDir = (dir: string) => {
return CommandInitPlugin(({ module, absPath }) => {
if (path.dirname(absPath) !== dir) {
console.log(
+new Date(),
`${module.name} is not in the correct directory!`,
);
return controller.stop();
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
});
};
```
Above, this simple plugin logs that the module has been loaded along with a timestamp. <br />
## Event Plugins
![control-plugins](/src/assets/docs/event-plugins.png)
- An event is emitted by discord.js.
- This event is passed to all plugins (**in order!!**),
- If all are successful,
The command is executed. Calling `controller.stop()` notifies sern that this command should not be run,
and command is ignored.
Can you predict the behavior of this command?
- Before loading into sern, this command module will check if this module is in the correct directory `other`.
- Before an event occurs, this command module will check if the user has the id `182326315813306368`.
:::tip
Event Plugins are good for filtering, preconditions, parsing.
:::
If all plugins return `controller.next()`, this command replies `Pong 🏓`

View File

@@ -0,0 +1,16 @@
---
title: Sern Emitter
sidebar:
order: 11
---
You're shipped with the SernEmitter. This EventEmitter listens to
- command modules executing and its status, the `module.activate` event
- command modules registered and its status, the `module.register` event
- On default, sern creates a single SernEmitter for your bot process.
- any error that occurs, the `error` event
- `warn` events, where it is possible to throw errors
You can put these and other event listeners into [event modules](./first-event.md)!
<br/>View all <a href="https://sern.dev/docs/api/modules#serneventsmapping">events</a>

View File

@@ -0,0 +1,157 @@
---
title: Services
sidebar:
order: 8
---
:::tip
This is version 3 api only!!
:::
:::tip
TLDR: The direct upgrade to useContainer. if you set up a bot with create-bot, check dependencies.d.ts.
Dependencies are the types that Services uses.
:::
You need someway to use dependencies in your command module. Services to the rescue!
```ts title="src/dependencies.d.ts"
import { CoreDependencies, Singleton } from "@sern/handler";
import { Client } from "discord.js";
interface Dependencies extends CoreDependencies {
"@sern/client": Singleton<Client>;
}
```
Recall, some keys in Dependencies are special.
> Special key dependency must implement its contracts.
>
> - `@sern/client`: Your discord client. -> [Emitter](../../api/interfaces/Emitter)
> - `@sern/logger`: Log data -> [Logging](../../api/interfaces/Logging)
> - `@sern/errors`: Handling errors and lifetime -> [ErrorHandling](../../api/interfaces/ErrorHandling)
> - `@sern/modules`: Managing all command modules -> [ModuleManager](../../api/interfaces/ModuleManager)
> - `@sern/emitter`: is the key to emit events and occurences in a project -> [Emitter](../../api/interfaces/Emitter)
Lets try to access the client you provided.
```ts title="src/commands/ping.ts"
import { Service } from "@sern/handler";
export default commandModule({
// ...
execute: (ctx) => {
//Client!
const client = Service("@sern/client");
},
//
});
```
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Safety
- Services cannot be called in other services while makeDependencies is forming.
<Tabs>
<TabItem value="good" label="A good example">
Lets pass a logger into our database.
```ts title="index.ts" showLineNumbers
await makeDependencies({
build: root => root
//Overriding the default logger provided.
.upsert({ '@sern/logger': single(() => new Logger()) })
// Wiring our logger into the database.
.add(ctx => {
return { database: single(() => new Database(ctx['sern/logger']))) }
})
})
```
</TabItem>
<TabItem value="bad" label="Don't do this">
```ts title="index.ts" showLineNumbers
await makeDependencies({
build: (root) =>
root
//Overriding the default logger provided.
.upsert({ "@sern/logger": single(() => new Logger()) })
// Wiring our logger into the database.
// We wire our database incorrectly. Logger should be passed INTO the constructor
.add({ database: single(() => new Database()) }),
});
```
```ts title="index.ts" showLineNumbers
import { Service, makeDependencies } from "@sern/handler";
//Calling Service prematurely!
const logger = Service("@sern/logger");
class Database {
constructor() {
this.logger = logger;
}
}
```
This is a code smell anyway. It breaks encapsulation and defeats the purpose of wiring dependencies
</TabItem>
</Tabs>
- Services can only be used after sern has made dependencies.
- Calling a service before will crash your application.
- Services can be safely used outside of commandModules.
- Be careful to not cause too many side effects.
- You will need to wire dependencies together.
<Tabs>
<TabItem value="good" label="A good example">
```ts title="index.ts" showLineNumbers
await makeDependencies(...pass your options here)
```
```ts title="commands/ping.ts" showLineNumbers
// This is guaranteed to be defined if configured correctly
import { Service } from "@sern/handler";
const client = Service("@sern/client");
```
</TabItem>
<TabItem value="bad" label="Don't do this">
```ts title="index.ts" showLineNumbers
import { Service, makeDependencies } from "@sern/handler";
/* DON'T USE SERVICES BEFORE CALLING makeDependencies */
const logger = Service("@sern/logger");
await makeDependencies();
```
</TabItem>
</Tabs>
- Services can only be used after sern has made dependencies.
- Calling a service before will crash your application.
- Services can be safely used outside of commandModules.
- Be careful to not cause too many side effects.
## Related api
- use `Service` for single dependency.
- use `Services` for multiple dependencies.

Some files were not shown because too many files have changed in this diff Show More