This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
FirstBot is a modular Discord bot written in JavaScript using discord.js v14. It uses a plugin-based architecture for commands and event handlers.
npm install # Install dependencies
npm test # Run tests (currently runs npm build .)
node index.js # Run the bot locallyFor deployment as a systemd service:
sudo cp system/firstbot.service /etc/systemd/system/
sudo systemctl enable --now firstbotThe bot uses dynamic require() to load commands and events at startup:
-
Commands (
commands/): Each.jsfile exports arunfunction:exports.run = (client, message, args) => { ... }
Commands are stored in
client.commands(a discord.js Collection) and can be hot-reloaded via--reload <command>. -
Events (
events/): Each file name maps to a Discord.js event (e.g.,messageCreate.js→messageCreateevent):module.exports = (client, message) => { ... }
Copy config.json.sample to config.json with your Discord bot token and command prefix:
{
"token": "YOUR_BOT_TOKEN",
"prefix": "--"
}The config is attached to the client object as client.config.
events/message.jsreceives all messages- Ignores bot messages and non-prefixed messages
- Parses command name and arguments
- Looks up command in
client.commandsEnmap - Executes the command's
runfunction
Create a new file in commands/ (e.g., commands/mycommand.js):
exports.run = (client, message, args) => {
message.channel.send("Response here");
};The command will be available as --mycommand (using the configured prefix).
Create a new file in events/ named after the Discord.js event (e.g., events/guildMemberAdd.js):
module.exports = (client, member) => {
// Handle new member
};- Never commit
config.jsonwith real tokens (it's in.gitignore) - The bot runs on Node.js 24+
- Uses discord.js v14