ItsMyBot Docs

Configuration

Define typed server configuration and dashboard form hints.

Plugin configuration is guild-scoped. Server owners edit values in the dashboard; plugin code reads values from ctx.config.

Define config

Keep the config type and defaults in src/config.ts.

import {  } from "itsmybot";

export interface Config extends <string, unknown> {
  /**
   * @title Greeting
   * @description Text used in slash command replies.
   * @minLength 1
   * @maxLength 80
   */
  : string;

  /**
   * @title Emoji
   * @description Prefix displayed before generated messages.
   * @placeholder :wave:
   */
  : string;

  /**
   * @title Public replies
   * @description When enabled, command replies are visible to everyone.
   */
  : boolean;
}

export const  = <Config>({
  : "Welcome",
  : ":wave:",
  : false,
});

.publicReplies;

Export defaultConfig from src/index.ts:

export { defaultConfig } from "./config";

Read config

All command and event contexts expose ctx.config.

import type {  } from "itsmybot";

import type { Config } from "./config";

function (: <Config>) {
  return .(
    `${..} ${..}`,
    { : !.. },
  );
}

Dashboard hints

Use JSDoc tags on exported config fields. These comments are part of the author-facing contract because the dashboard schema is derived from them.

export interface Config extends Record<string, unknown> {
  /**
   * @title Welcome message
   * @description Message sent when a member joins.
   * @widget message-builder
   * @rows 8
   * @minLength 1
   * @maxLength 500
   */
  welcomeMessage: string;

  /**
   * @title Announcement channel
   * @widget channel-select
   * @channelTypes text,announcement
   */
  announcementChannelId?: string;

  /**
   * @title Moderator roles
   * @widget role-select
   */
  moderatorRoleIds: string[];
}

Supported widgets:

  • textarea
  • message-builder
  • channel-select
  • role-select

Useful validation tags:

  • @minLength
  • @maxLength
  • @placeholder
  • @rows
  • @channelTypes

Optional values

Use optional fields only when command logic can run without the value.

interface Config extends <string, unknown> {
  ?: string;
  : string;
}

function (: Config) {
  return config. ?? .;
config: Config
}

If a value is required for core behavior, make it required and provide a safe default.

What belongs in config

Good config values:

  • message templates.
  • feature toggles.
  • channel or role selections.
  • small numeric limits.

Poor config values:

  • runtime counters.
  • per-user state.
  • data that changes on every event.
  • secrets.

Use ctx.kv or declared storage for runtime state.

On this page