Skip to main content
Technical overview of the bot’s internal architecture, event pipeline, and module loading system.

Startup Flow

The entry point is src/index.js:
Since client.start() is not awaited, the Express server starts concurrently with Discord login.

Command Loading

Slash Commands (src/commands/slash/)

Loaded by src/handlers/commands.js. Files are organized in category subdirectories:
Each command exports { data, run }:
  • dataSlashCommandBuilder output (.toJSON())
  • run(client, interaction) — async command handler
Commands are stored in client.collection.interactioncommands and client.applicationcommandsArray.

Developer Commands (src/commands/devOnly/)

Same structure as slash commands but loaded into client.collection.developercommands. Deployed to config.handler.guildId via REST API (separate from regular slash command registration). Developer commands may set options: { developers: true } to restrict access.

Prefix Commands (src/commands/prefix/)

Export { data: { name, description, aliases?, permissions?, developers? }, run }. Loaded into client.collection.prefixcommands with aliases in client.collection.aliases. Only active when config.handler.commands.prefix is true.

Event System

Event Registration (src/handlers/events.js)

The event handler scans src/events/ subdirectories:

Interaction Validation Pipeline

When an interactionCreate event fires, all validators run in sequence:
Each validator:
  1. Checks if the interaction matches its type (e.g., isChatInputCommand())
  2. Finds the matching command/component from local files
  3. Validates permissions (developer, staff, NSFW, test mode, user/bot perms)
  4. Calls run() if validation passes
See Security for permission gate details.

Guild Event Handlers

These handle non-interaction events: The Guild interactionCreate.js and components.js files include guards (interaction.replied || interaction.deferred) to avoid double-executing commands already handled by validators.

Component System

Component Loading (src/handlers/components.js)

Scans src/components/ subdirectories:
Each component exports { customId, run }.

Component Routing

Components are routed by customId matching. Some components are handled by the validator pipeline, while others use inline collectors (e.g., economy buttons page1/page2, help help-menu).

Context Menus

Files in src/contextmenus/ export { data, run } where data includes type (2 for User, 3 for Message). Registered at ready time via src/events/ready/registerContextMenus.js on DEV_GUILD_ID.

Command Deployment

Two deployment paths exist:
  1. Slash commandssrc/events/ready/registerCommands.js diffs local commands against Discord API and creates/edits/deletes as needed on DEV_GUILD_ID
  2. Developer commandssrc/handlers/deploy.js bulk-overwrites guild commands on config.handler.guildId using the developer command array

Database Layer

The database layer uses Prisma v6 with the MongoDB provider. See Database for model details.
The schema files maintain backward-compatible import paths so existing require("../schemas/EcoSchema") calls continue to work, but now return Prisma model delegates instead of Mongoose models.

Express Server

src/server.js starts a minimal Express server on 0.0.0.0:8080 that serves a single health-check endpoint at /. Returns a plain text message confirming the bot is online.

Utility Functions

src/functions/index.js

src/utils/