Skip to content
sern

ContextMenuUser

Extends

Properties

description?

optional description: string

Inherited from

Module.description

Source

src/types/core-modules.ts:122


execute()

execute: (ctx, tbd) => unknown

Parameters

ctx: UserContextMenuCommandInteraction<CacheType>

tbd: SDT

Returns

unknown

Overrides

Module.execute

Source

src/types/core-modules.ts:216


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


plugins

plugins: InitPlugin<any[]>[]

Inherited from

Module.plugins

Source

src/types/core-modules.ts:121


type

type: CtxUser

Overrides

Module.type

Source

src/types/core-modules.ts:215