How konik-yt/admin-bot works
Purpose and runtime
This is a Node.js Discord bot organized around Discord event handlers and category-based message commands. The process entry point is likely index.js; Procfile supports deployment on a process host. Core runtime dependencies are declared in package.json.
Startup and event boundary
index.js likely initializes the Discord client, persistence connections, and event registration. Incoming platform events are separated from business commands:
• events/message.js receives messages and is the primary command-ingress boundary.
• events/guildCreate.js and events/guildDelete.js handle bot installation/removal from Discord guilds.
• handlers/command.js resolves and executes commands after message handling.
Command dispatch and extension model
Commands are filesystem-organized by domain, making each command module an independently extensible capability. handlers/command.js is the central routing layer between parsed message input and command implementations. Representative command domains:
• Currency: commands/currency/balance.js, commands/currency/transfer.js, commands/currency/gamble.js
• Moderation: commands/moderation/ban.js, commands/moderation/warn.js, commands/moderation/report.js
• Mute management: commands/mute/mute.js, commands/mute/unmute.js
• Server/user utilities: commands/misc/prefix.js, commands/info/help.js, commands/fun/giveaway.js
Primary control flow
The expected request path is: Discord message → events/message.js → command parsing/validation → handlers/command.js → a module under commands/ → Discord API actions and/or persistence → response message. Administrative commands such as commands/moderation/restart.js may affect process lifecycle, while commands/misc/prefix.js changes guild-specific dispatch behavior.
Persistence boundary
The repository contains both SQLite-oriented and MongoDB/Mongoose-oriented persistence artifacts:
• db.js
• json.sqlite
• utils/mongoose.js
• models/guild.js
models/guild.js is the likely schema boundary for guild configuration, including data needed by lifecycle events and per-guild behavior such as command prefixes. The coexistence of db.js/json.sqlite and Mongoose should be treated as an architectural integration point: command features may depend on one or both stores.
Shared behavior and configuration
functions.js is the likely shared utility/service layer used across events and commands. config.json is the repository-level configuration boundary, likely supplying bot credentials, defaults, or operational settings; it should remain distinct from mutable guild state in models/guild.js.
External systems and operational boundaries
The primary external service is Discord, accessed by the client initialized from index.js and invoked by event/command modules. MongoDB is implied by utils/mongoose.js and models/guild.js; SQLite is materially present through db.js and json.sqlite. Deployment process configuration is represented by Procfile.
Components 19
Bot Runtime
- Process Host · Defines the deployed process command.
Procfile - Node Dependencies
package.json - Bot Configuration · Static credentials and operational defaults.
config.json - Bot Bootstrap · Initializes the Discord client, data connections, and handlers.
index.js
Discord Events
- Message Ingress · Validates incoming messages before command dispatch.
events/message.js - Guild Installed
events/guildCreate.js - Guild Removed
events/guildDelete.js
Command Extensions
- Command Dispatcher · Resolves parsed command input to command modules.
handlers/command.js - Currency Commands · Balance, transfer, and gambling capabilities.
commands/currency/balance.js - Moderation Commands · Ban, warn, report, and restart capabilities.
commands/moderation/ban.js - Mute Commands · Mute and unmute management.
commands/mute/mute.js - Guild Utilities · Prefix, help, and giveaway capabilities.
commands/misc/prefix.js
Persistence
- Mongo Connection
utils/mongoose.js - Guild State Model · Stores mutable guild configuration such as prefixes.
models/guild.js - MongoDB
- SQLite Adapter
db.js - SQLite Data
json.sqlite
Other components
- Discord Platform
- Shared Functions
functions.js
Connections 23
- Process Host → Bot Bootstrap: starts
- Node Dependencies → Bot Bootstrap: provides runtime dependencies
- Bot Configuration → Bot Bootstrap: supplies settings
- Bot Bootstrap → Discord Platform: connects client
- Discord Platform → Message Ingress: message events
- Discord Platform → Guild Installed: guild create
- Discord Platform → Guild Removed: guild delete
- Message Ingress → Command Dispatcher: parsed command
- Command Dispatcher → Currency Commands: routes currency commands
- Command Dispatcher → Moderation Commands: routes moderation commands
- Command Dispatcher → Mute Commands: routes mute commands
- Command Dispatcher → Guild Utilities: routes utility commands
- Message Ingress → Guild State Model: reads guild settings
- Guild Installed → Guild State Model: creates guild state
- Guild Removed → Guild State Model: removes guild state
- Guild Utilities → Guild State Model: updates prefix
- Currency Commands → SQLite Adapter: persists feature data
- Moderation Commands → Shared Functions: uses shared behavior
- Currency Commands → Discord Platform: sends responses
- Moderation Commands → Discord Platform: performs actions
- Mongo Connection → MongoDB: connects
- Guild State Model → Mongo Connection: uses connection
- SQLite Adapter → SQLite Data: reads and writes