Skip to content
sern

DiscordEventCommand

Since

1.0.0

Extends

Type parameters

T extends keyof ClientEvents = keyof ClientEvents

Properties

description?

optional description: string

Inherited from

Module.description

Source

src/types/core-modules.ts:126


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


meta

meta: object

absPath

absPath: string

id

id: string

Inherited from

Module.meta

Source

src/types/core-modules.ts:127


name?

optional name: T

Overrides

Module.name

Source

src/types/core-modules.ts:297


onEvent

onEvent: ControlPlugin<any[]>[]

Inherited from

Module.onEvent

Source

src/types/core-modules.ts:124


plugins

plugins: InitPlugin<any[]>[]

Inherited from

Module.plugins

Source

src/types/core-modules.ts:125


type

type: Discord

Overrides

Module.type

Source

src/types/core-modules.ts:298

Methods

execute()

execute(…args): unknown

Parameters

• …args: ClientEvents[T]

Returns

unknown

Overrides

Module.execute

Source

src/types/core-modules.ts:299