Docs
Developer Documentation

Internal API Specification

Exhaustive API specification covering every property, method, and signature on the Medusa instance.

This reference documents every property, service, method signature, and parameter exposed across Medusa. Every building block receives this instance as this.medusa.

Root Medusa Properties

PropertyTypeDescription
productstringConstant product name ("Medusa").
versionstringRunning version string (e.g. "1.0.0.0").
startedAtDayjsDay.js timestamp representing the start time of the bot.
runningbooleantrue once boot sequence completes and modules are active.
stoppingbooleantrue while the shutdown lifecycle is executing.
licenseobject | nullLicense metadata returned from validation servers.
messagestring | nullLicensing alert message or null.
configConfigRoot configuration manager for config.json.
consoleLayoutStructured console logging and ANSI color builder.
eventsEventEmitterGlobal event emitter (medusa.ready, medusa.discord.ready, etc.).
databaseDatabaseSequelize database manager and connection supervisor.
settingsSettingsKey-value settings database storage manager.
localesLocalesLocalization catalog for all 16 supported languages.
embedsEmbedsStandard Discord embed message builder and dispatcher.
emojisEmojisDiscord application emoji registry and custom icons.
logsLogsDiscord audit logging channel dispatcher.
permissionsPermissionsRole, user, and rank authorization supervisor.
auditAuditSystem audit log database manager.
modulesModulesModule manager, registry, and subsystem loader.
leaderboardsLeaderboardsLeaderboard provider registry and pagination engine.
docsDocsIn-dashboard module documentation filesystem reader.
dataDataOn-disk file storage manager in the root data/ directory.
apiApiExpress HTTP REST API server on port 3001.
discordDiscordDiscord.js client manager and gateway supervisor.
dashboardDashboardNext.js web dashboard process supervisor.
zeroZeroZero Development licensing and update connection API.

Root Medusa Methods

hasAddon(name)

Checks whether the active server license includes a specific commercial addon.

  • Signature: hasAddon(name: string): boolean
  • Example:
    if (this.medusa.hasAddon("Economy")) {
    }

emitAsync(event, ...args)

Sequentially invokes all asynchronous listeners registered on this.medusa.events.

  • Signature: emitAsync(event: string, ...args: any[]): Promise<void>

wait(ms)

Promise-based execution delay helper.

  • Signature: wait(ms: number): Promise<void>
  • Example:
    await this.medusa.wait(2000);

restart()

Performs a graceful shutdown and triggers process restart with exit code 75.

  • Signature: restart(): Promise<void>

stop(code)

Gracefully stops all modules, clocks, Discord sessions, HTTP servers, and database connections.

  • Signature: stop(code?: number): Promise<void>

installPackages(...packages)

Checks node_modules for missing npm packages and installs them automatically using bun add or npm install.

  • Signature: installPackages(...packages: string[]): Promise<void>

Subsystem Accessors (this.medusa.modules)

Models (this.medusa.modules.models)

  • get(module: string, name: string): Models | null

Handlers (this.medusa.modules.handlers)

  • get(module: string, name: string): Handlers | null

Routes (this.medusa.modules.routes)

  • get(module: string, name: string): Routes | null

Commands (this.medusa.modules.commands)

  • get(module: string, name: string): Commands | null
  • find(name: string): Commands | null - Searches all loaded modules.

Events (this.medusa.modules.events)

  • get(module: string, name: string): Events | null

Clocks (this.medusa.modules.clocks)

  • get(module: string, name: string): Clocks | null

Configuration (this.medusa.modules.config)

  • get(module: string, name: string): Configs | null
  • value(module: string, name: string, key: string): any
  • values(module: string, name: string): object

Language & Phrases (this.medusa.modules.lang)

  • get(module: string, name: string): Langs | null
  • value(module: string, name: string, key: string): any
  • values(module: string, name: string): object
  • phrase(module: string, name: string, key: string, tokens?: object): string
  • embed(module: string, name: string, key: string, tokens?: object): EmbedBuilder

Logs (this.medusa.modules.logs)

  • get(module: string, name: string): Logs | null

Custom Pages (this.medusa.modules.pages)

  • get(module: string, name: string): Pages | null
  • list(): Array<object>

Leaderboards (this.medusa.modules.leaderboards)

  • get(module: string, name: string): Leaderboards | null
  • all(): Array<{ module: string, provider: Leaderboards, descriptor: object }>

Automation Nodes (this.medusa.modules.nodes)

  • get(module: string, name: string): Nodes | null
  • all(): Array<{ module: string, node: Nodes, descriptor: object }>

Embeds Service (this.medusa.embeds)

MethodSignatureDescription
success(text)(text: string) => EmbedBuilderReturns an embed with green #22c55e accent and check emoji.
warn(text)(text: string) => EmbedBuilderReturns an embed with amber #f59e0b accent and warning emoji.
error(text)(text: string) => EmbedBuilderReturns an embed with red #ef4444 accent and cross emoji.
info(emoji, message, colour)(emoji: string, message: string, colour?: string) => EmbedBuilderReturns an embed with custom emoji and optional hex color.
resolve(template, tokens, options)(template: object, tokens?: object, options?: object) => EmbedBuilderResolves embed object with token replacements, footer, and timestamp.
normalize(template)(template: object) => objectNormalizes author, footer, thumbnail, image, and color into valid Discord structure.
hex(value)(value: any) => string | nullFormats number or text string into a normalized 6-character hex code ("#22c55e").
fill(value, tokens)(value: any, tokens?: object) => anyRecursively replaces %key%, <key>, and custom emoji placeholders across strings, arrays, and objects.
serverName()() => stringReturns configured server name or Discord guild name.
serverIcon()() => string | nullReturns server icon URL or bot avatar URL.
footerName()() => stringReturns server name if watermark addon is present; otherwise returns product name.
send(channelId, content, template, tokens, buttons, selectMenu, components, flags, embeds)(channelId: string, ...) => Promise<Message>Dispatches complete message with embeds and interactive components.
buildComponents(buttons, selectMenu, rawComponents)(buttons?: Array, selectMenu?: object, rawComponents?: Array) => ArrayBuilds Discord action rows containing buttons and select menus.

Emoji Registry (this.medusa.emojis)

MethodSignatureDescription
get(name)(name: string) => stringReturns custom Discord emoji markup (e.g. <:check:12345>) or empty string.
has(name)(name: string) => booleanChecks whether an emoji name exists in the registry.
names()() => Array<string>Returns all 130+ registered preset emoji names.
sync()() => Promise<void>Uploads missing preset icons to Discord application emojis.

Discord Supervisor (this.medusa.discord)

Property / MethodSignatureDescription
clientClientUnderlying Discord.js Client instance.
ready()() => booleanReturns true if Discord client is authenticated and connected to the gateway.
resources()() => Promise<object>Fetches { guildId, channels, categories, roles, emojis, serverIcon }.
post(channelId, payload)(channelId: string, payload: object) => Promise<Message>Posts a message to a text channel.
temporary(channelId, payload, seconds)(channelId: string, payload: object, seconds: number) => Promise<Message>Posts a message that automatically deletes after the specified duration.
setUsername(username)(username: string) => Promise<void>Updates the Discord bot account username.
setAvatar(avatar)(avatar: Buffer | string) => Promise<void>Updates the Discord bot account avatar image.
setPresence(config)(config: object) => voidUpdates Discord presence activity, status, and rotating messages.
prefix()() => stringReads the active prefix for prefix-based commands.

Permissions Supervisor (this.medusa.permissions)

MethodSignatureDescription
guard(interaction, node)(interaction: Interaction, node: string) => Promise<boolean>Evaluates member permissions. If denied, automatically responds with an ephemeral error embed and returns false.
allowed(member, node)(member: GuildMember, node: string) => booleanEvaluates whether a member is authorized for a command or interaction node.
deny(interaction)(interaction: Interaction) => Promise<void>Sends the localized denial embed as an ephemeral reply.
ranks()() => Array<object>Returns all configured permission ranks.
held(memberOrUserId)(memberOrUserId: any) => Array<object>Returns all ranks held by a member based on roles and user ID.
abilities(memberOrUserId)(memberOrUserId: any) => { grantAll: boolean, abilities: Array<string> }Resolves dashboard permissions held by the member.
allowedDashboard(memberOrUserId, node)(memberOrUserId: any, node: string) => booleanChecks whether user has permission to view a dashboard page.

System Audit (this.medusa.audit)

MethodSignatureDescription
record(entry)(entry: { type: string, actorId?: string, actorTag?: string, command?: string, success?: boolean, detail?: object, guildId?: string }) => Promise<void>Records an audit entry to the database. Queues in memory if database is temporarily offline.
list(filter)(filter?: { guildId?: string, type?: string, limit?: number }) => Promise<Array<object>>Queries audit history ordered descending by creation date.

Disk Storage (this.medusa.data)

MethodSignatureDescription
module(id, ...segments)(id: string, ...segments: string[]) => stringResolves safe path inside data/<module>/.
path(...segments)(...segments: string[]) => stringResolves safe path inside root data/.
ensure(...segments)(...segments: string[]) => stringCreates directory structure recursively if it does not exist.
exists(...segments)(...segments: string[]) => booleanChecks whether file or directory exists.
remove(...segments)(...segments: string[]) => voidDeletes file or directory recursively.

Settings Storage (this.medusa.settings)

MethodSignatureDescription
get(key)(key: string) => anyReads setting value from in-memory cache.
set(key, value)(key: string, value: any) => Promise<any>Writes value to memory and upserts to database table medusa_settings.
delete(key)(key: string) => Promise<void>Removes setting from memory and database.
all()() => objectReturns full key-value map of all stored settings.
reload()() => Promise<number>Reloads all settings from the database into memory cache.

Global Settings Catalog

Setting KeyTypeDescription
BOT_IDstringDiscord client ID of the bot application.
GUILD_IDstringPrimary Discord server snowflake ID.
DISCORD_TOKENstringDiscord bot secret token.
ACCENT_COLOURstringDefault hex color applied across embeds and UI.
LANGUAGEstringActive language code ("en", "fr", "de", etc.).
SERVER_NAMEstringCustom server name override for messages.
DASHBOARD_NAMEstringCustom branding name for the web dashboard.
API_KEYSArray<object>Registered external API authentication keys.
ALLOWED_IPSArray<string>Whitelisted client IP addresses.
MODULESArray<string>List of disabled module folder names.
COMMANDSobjectCustom command prefixes and enabled toggles.
PERMISSIONSobjectConfigured rank priorities, roles, and ability maps.
module:<id>objectConfiguration values bucket for module <id>.
lang:<id>objectLanguage overrides bucket for module <id>.
logs:<id>objectChannel assignments and toggles for module <id>.

Localization Catalog (this.medusa.locales)

MethodSignatureDescription
list()() => Array<object>Returns all 16 supported language objects with code, name, native, and discord mappings.
codes()() => Array<string>Returns array of all 16 locale code strings.
active()() => stringReturns the currently active language code from settings.
isSupported(code)(code: string) => booleanChecks if a language code is supported.
moduleName(id, locale)(id: string, locale?: string) => stringResolves localized module display name from module.<id>.name in common.json.

Database Supervisor (this.medusa.database)

Property / MethodSignatureDescription
sequelizeSequelizeActive Sequelize ORM database connection.
healthybooleantrue when database connection is live and passing health ticks.
sync(options)(options?: object) => Promise<void>Synchronizes all Sequelize models and runs column migrations.
close()() => Promise<void>Closes database connections cleanly.

Structured Console (this.medusa.console)

Property / MethodSignatureDescription
log(level, text)(level: string, text: string) => voidLogs formatted, timestamped output to stdout and daily log file.
levelsobjectSeverity levels: { info, success, warning, error, debug, startup }.
colorsColorsANSI color painter: colors.green(text), colors.red(text), colors.bright.bold.white(text), etc.
error(target, extra, footer)(target: Error | string, extra?: string, footer?: string) => voidRenders a styled ASCII error panel with stack trace and issue location.

On this page