Saltearse al contenido
sern

BothCommand

Extends

Properties

description

description: string

Overrides

Module.description

Source

src/types/core-modules.ts:284


execute()

execute: (ctx, tbd) => unknown

Parameters

ctx: Context

tbd: SDT

Returns

unknown

Overrides

Module.execute

Source

src/types/core-modules.ts:286


locals

locals: Dictionary

Custom data storage object for module-specific information. Plugins and module code can use this to store and retrieve metadata, configuration, or any other module-specific information.

Description

A key-value store that allows plugins and module code to persist data at the module level. This is especially useful for InitPlugins that need to attach metadata or configuration to modules.

Example

1
// In a plugin
2
module.locals.registrationDate = Date.now();
3
module.locals.version = "1.0.0";
4
module.locals.permissions = ["ADMIN", "MODERATE"];

Example

1
// In module execution
2
console.log(`Command registered on: ${new Date(module.locals.registrationDate)}`);

Example

1
// Storing localization data
2
module.locals.translations = {
3
en: "Hello",
4
es: "Hola",
5
fr: "Bonjour"
6
};

Example

1
// Storing command metadata
2
module.locals.metadata = {
3
category: "admin",
4
cooldown: 5000,
5
requiresPermissions: true
6
};

Remarks

  • The locals object is initialized as an empty object ({}) by default
  • Keys should be namespaced to avoid collisions between plugins
  • Values can be of any type
  • Data persists for the lifetime of the module
  • Commonly used by InitPlugins during module initialization

@best-practices

  1. Namespace your keys to avoid conflicts:

    1
    module.locals['myPlugin:data'] = value;
  2. Document the data structure you’re storing:

    1
    interface MyPluginData {
    2
    version: string;
    3
    timestamp: number;
    4
    }
    5
    module.locals['myPlugin:data'] = {
    6
    version: '1.0.0',
    7
    timestamp: Date.now()
    8
    } as MyPluginData;
  3. Use type-safe accessors when possible:

    1
    const getPluginData = (module: Module): MyPluginData =>
    2
    module.locals['myPlugin:data'];

Inherited from

Module.locals

Source

src/types/core-modules.ts:195


meta

meta: object

absPath

absPath: string

id

id: string

Inherited from

Module.meta

Source

src/types/core-modules.ts:123


name?

optional name: string

Inherited from

Module.name

Source

src/types/core-modules.ts:119


onEvent

onEvent: ControlPlugin<any[]>[]

Inherited from

Module.onEvent

Source

src/types/core-modules.ts:120


options?

optional options: SernOptionsData[]

Source

src/types/core-modules.ts:285


plugins

plugins: InitPlugin<any[]>[]

Inherited from

Module.plugins

Source

src/types/core-modules.ts:121


type

type: Both

Overrides

Module.type

Source

src/types/core-modules.ts:283