Developer Tools
Relevant source files
The following files were used as context for generating this wiki page:
The Developer Tools feature is a restricted set of commands and interfaces designed for bot owners and developers to manage, monitor, and configure the bot's core functionalities at a global level. It is primarily accessed through the /dev slash command, which serves as a gateway to various sub-modules for tasks like server management, module reloading, and direct database configuration for presence, AI, and bot statistics.
These tools are critical for maintenance and debugging, providing privileged access to operations that are not exposed to regular server administrators. The system is built around a central database schema (dev-config) that stores global settings, which are then manipulated through a series of interactive command handlers.
Architecture Overview
The Developer Tools are initiated by the /dev command. If no specific subcommand is provided, it opens an interactive "Developer Hub". Otherwise, it routes to a dedicated subcommand handler. All developer-level configurations are persisted in the dev-config collection in MongoDB.
Command Flow
The following diagram illustrates how the /dev command routes the user to either a specific subcommand or the main developer hub.
Sources: src/commands/dev/dev.ts:25-33
Developer Hub
The Developer Hub is the central interface for accessing most developer tools. It is presented as a Discord embed with a select menu, allowing the developer to choose from various management modules.
Sources: src/handlers/dev/main-hub.ts
Hub Options
The main hub provides access to the following modules:
| Option | Description | Handler File |
|---|---|---|
presence | Manage the bot's presence (status, activity). | src/handlers/dev/presence/main-hub.ts |
mina-ai | Configure global settings for the AI responder. | src/handlers/dev/mina-ai/main-hub.ts |
trig-settings | Trigger guild-specific setup flows. | src/handlers/dev/trig-settings.ts |
list-servers | View a paginated list of all servers the bot is in. | src/commands/dev/sub/listServers.ts |
reload | Reload commands, events, or context menus from disk. | src/handlers/dev/reload.ts |
dev-commands | Enable or disable developer commands globally. | src/handlers/dev/dev-commands.ts |
Sources: src/handlers/dev/main-hub.ts:23-44
Interaction Flow
This diagram shows the user interaction flow when using the Developer Hub.
Sources: src/handlers/dev/main-hub.ts:18-62
Database Schema (dev-config)
All global developer settings are stored in a single document within the dev-config collection, defined by the Dev.ts schema. This centralized approach simplifies management of bot-wide configurations.
Sources: src/database/schemas/Dev.ts
ER Diagram
The diagram below shows the structure of the dev-config schema.
Sources: src/database/schemas/Dev.ts:11-92
PRESENCE Configuration
This sub-document controls the bot's Discord presence (status and activity).
| Field | Type | Default Value | Description |
|---|---|---|---|
ENABLED | Boolean | true | Toggles the custom presence. |
STATUS | String | idle | The bot's status (online, idle, dnd, invisible). |
TYPE | String | CUSTOM | The activity type (PLAYING, LISTENING, etc.). |
MESSAGE | String | "We'll show them..." | The text displayed in the activity. |
URL | String | https://twitch.tv/iamvikshan | The URL for STREAMING activity type. |
| Sources: src/database/schemas/Dev.ts:12-34 |
AI_CONFIG Configuration
This sub-document holds global settings for the Mina AI responder feature.
| Field | Type | Default Value | Description |
|---|---|---|---|
globallyEnabled | Boolean | false | Master switch for the AI feature. |
model | String | gemini-flash-latest | The AI model to use. |
maxTokens | Number | 1024 | Maximum tokens for an AI response. |
timeoutMs | Number | 20000 | Timeout for AI API requests. |
systemPrompt | String | (from prompt.md) | The base instruction prompt for the AI. |
temperature | Number | 0.7 | The creativity/randomness of the AI. |
dmEnabledGlobally | Boolean | true | Whether the AI can respond in DMs. |
upstashUrl | String | (from config) | URL for the Upstash vector database. |
updatedAt | Date | Date.now | Timestamp of the last update. |
updatedBy | String | null | The user ID of the developer who last updated the config. |
| Sources: src/database/schemas/Dev.ts:41-76 |
BOT_STATS Data
This sub-document caches general statistics about the bot, which can be updated periodically. The /bot stats command triggers an update to this data.
| Field | Type | Default Value | Description |
|---|---|---|---|
guilds | Number | 0 | Total number of guilds the bot is in. |
users | Number | 0 | Total number of users across all guilds. |
channels | Number | 0 | Total number of channels across all guilds. |
ping | Number | 0 | The bot's websocket ping to Discord. |
uptime | Number | 0 | The bot's process uptime in seconds. |
lastUpdated | Date | Date.now | Timestamp of the last stats update. |
| Sources: src/database/schemas/Dev.ts:79-99, src/commands/bot/sub/botstats.ts:74-84 |
Key Subcommands
listservers
This command provides a paginated list of all guilds (servers) the bot is a member of. It's essential for monitoring the bot's reach and for administrative tasks like manually leaving a server.
The command flow is as follows:
- Fetch all guilds from the
client.guilds.cache. - Paginate the list of guilds.
- For each page, create an embed listing the server name, ID, owner, and member count.
- Use interactive buttons (
prev,next) for navigation.
reload
This command allows a developer to hot-reload different parts of the bot's code without a full restart. This is crucial for rapid development and patching.
The user is presented with a dropdown menu to select which module to reload.
{
"dev": {
"reload": {
"placeholder": "select what to reload...",
"option": {
"commands": { "label": "commands", "description": "reload all slash commands" },
"events": { "label": "events", "description": "reload all event handlers" },
"contexts": { "label": "contexts", "description": "reload all context menus" },
"all": { "label": "all", "description": "reload everything" }
}
}
}
}
Sources: src/data/respGuild.json:65-88
Upon selection, the bot dynamically unloads and reloads the corresponding command, event, or context handlers from their source files.
Sources: src/commands/dev/dev.ts:29