Running the bot
Requirements, configuration, scripts and troubleshooting for whoever hosts Kijiio Bot.
This page is for whoever runs the bot's process. Server admins only need the earlier pages.
Requirements
- Node.js 22.15 or newer, and PM2 installed globally.
- A MariaDB database. The ticket system creates and updates its own tables when it starts.
Configuration
Settings live in config.json (production) and config.dev.json (development) as PM2 env blocks, or in the hep.gg secrets vault. The ones the ticket system depends on:
| Variable | What it is |
|---|---|
TOKEN | The bot token. |
TICKET_GUILD | ID of the server the ticket system belongs to. Ticket commands only work there, and in production they are only registered there. Blank turns the ticket system off. |
CONTROL_GUILD | Server where commands are registered in development. In development, TICKET_GUILD must be the same server. |
DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME | The MariaDB connection. Without it, ticket commands reply that the system is unavailable. |
INTENTS | Gateway intents. The bot needs only Guilds. |
If you use the vault, its values override the config files for any key it holds. Keep TICKET_GUILD out of the vault and set it in each config file, so development can point at a test server.
Scripts
| Command | What it does |
|---|---|
npm install --allow-remote=all | Installs dependencies. The flag is needed because packages come from npm.hep.gg. |
npm start | Builds and starts the production bot under PM2. |
npm run dev | Builds, then recompiles and restarts on every change. Stop it with Ctrl+C. |
npm run rebuild | Clears dist/ and builds from scratch. |
npm test | Builds and runs the test suite. |
npm run dev runs PM2 with its own home directory (.pm2/ in the project), so pressing Ctrl+C only stops the development bot, never other PM2 apps on the machine.
Troubleshooting
| What you see | Cause and fix |
|---|---|
| "Tickets are not available in this server." | The command was used outside TICKET_GUILD, or TICKET_GUILD is blank. Check the value, then run npm run rebuild in case an old build is loaded. |
| "The ticket system is unavailable..." | The database is not configured or could not be reached at startup. The log shows Ticket system failed to start with the reason. |
| "Tickets are not set up yet." | No Discord category is set. Run /ticket-admin setup. |
| "Ticket channels are full right now." | The ticket category, and the overflow category if set, each hold 50 channels. Set or empty an overflow category. |
| "I could not create your ticket channel because I am missing permissions." | The bot needs Manage Channels and Manage Roles, and must be able to see the ticket category. |
| "The transcript could not be saved, so nothing was deleted." | Usually the bot cannot post in the archive channel. Give it View Channel, Send Messages, Embed Links and Attach Files there, then press Close again. |
Error: Missing object id in the logs | INTENTS includes GuildPresences. Set it to Guilds and restart. |
| Commands do not appear | In development, check CONTROL_GUILD and look for Deployed N commands in the log. |
When the bot starts, it closes tickets whose channels were deleted while it was offline, and logs any ticket stuck partway through closing. Press Close in that ticket's channel to finish it.