Startup Flow
The entry point issrc/index.js:
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:
{ data, run }:
data—SlashCommandBuilderoutput (.toJSON())run(client, interaction)— async command handler
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 aninteractionCreate event fires, all validators run in sequence:
- Checks if the interaction matches its type (e.g.,
isChatInputCommand()) - Finds the matching command/component from local files
- Validates permissions (developer, staff, NSFW, test mode, user/bot perms)
- Calls
run()if validation passes
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:
{ customId, run }.
Component Routing
Components are routed bycustomId 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 insrc/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:- Slash commands —
src/events/ready/registerCommands.jsdiffs local commands against Discord API and creates/edits/deletes as needed onDEV_GUILD_ID - Developer commands —
src/handlers/deploy.jsbulk-overwrites guild commands onconfig.handler.guildIdusing the developer command array
Database Layer
The database layer uses Prisma v6 with the MongoDB provider. See Database for model details.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.