A Discord bot for Star Wars Galaxy of Heroes that provides slash commands for character info, guild data, arena tracking, and event management. Built with Discord.js v14, featuring sharding support, MongoDB persistence, and native TypeScript.
- Character & Ship Info: Detailed information about units, abilities, and recommended builds
- Guild Management: Track guild member data, tickets, and Territory War/Battle info
- Arena Tracking: Monitor arena ranks and receive payout alerts
- Event Calendar: Schedule and track in-game events with customizable countdowns
- Player Profiles: Link Discord accounts to ally codes for quick data access
- Localization: Multi-language support for bot and game data
- Patreon Integration: Premium features for supporters
- Node.js >= 25.2 (uses native TypeScript support)
- MongoDB instance (local or remote)
- Discord Bot Token from Discord Developer Portal
- Clone the repository:
git clone https://github.com/jmiln/SWGoHBot.git
cd SWGoHBot- Install dependencies:
npm install- Configure the bot:
cp .env.example .envEdit .env and add:
- Your Discord bot token
- Bot client ID and owner ID
- MongoDB connection URL
- Optional: webhook URLs, premium features
- Deploy slash commands to Discord:
npm run deploy- Start the bot:
npm start# Run bot
npm start
# Lint code with Biome
npm run lint
# Lint and auto-fix issues
npm run lint:write
# Type-check without emitting
tsc --noEmit
# Run all tests
npm test
# Run module or slash tests only
npm run test:modules
npm run test:slash
# Deploy slash commands to Discord
npm run deploy-
Entry Points:
swgohBotShard.ts- Shard manager for scaling across multiple instancesswgohBot.ts- Main bot initialization and client setup
-
Slash Commands:
slash/*.ts- Each extends base command class frombase/slashCommand.ts -
Event System:
events/*.ts- Discord event handlers auto-loaded byhandlers/eventHandler.ts -
Modules: Core utilities in
modules/including caching, API clients, and helper functions -
Database: MongoDB collections managed via
modules/guildConfig/for settings, events, polls, aliases -
Workers: Heavy processing offloaded to worker threads in
modules/workers/
- Discord.js v14 with sharding support
- Native TypeScript using Node.js type-stripping (no compilation step)
- MongoDB v7 for data persistence
- Piscina for worker thread management
- Biome for linting and formatting
- Formatter: Biome (4 spaces, 140 char width, double quotes, semicolons required)
- TypeScript: No
anytypes, import with.tsextensions, ESM modules - Testing: Node.js native test runner
Configuration is loaded from a .env file using Node.js's built-in process.loadEnvFile(). Copy .env.example to .env and fill in your values. Key variables:
- Discord:
DISCORD_TOKEN,CLIENT_ID,OWNER_ID - MongoDB:
MONGODB_URL - Game API:
SWAPI_URL,SWAPI_ACCESS_KEY,SWAPI_SECRET_KEY - Optional: webhook URLs, Patreon integration (
PATREON_*), image server URL
See docs/CONFIG.md for the full variable reference.
- Patreon - Unlock premium features
- Official Discord Server - Get help and suggest features
- Invite SWGoHBot - Add to your Discord server
- More frequent in-game data updates
- Arena rank change alerts via DM
- Channel logging for player rank changes
- Auto-updating payout countdown messages
- Guild ticket tracker with auto-updates
- Character unlock/upgrade notifications
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow the code style (run
npm run lint:write) - Write tests for new features
- Commit your changes (the pre-commit hook will run lint, type-check, and tests automatically)
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use Biome for code formatting and linting
- Add tests in
test/directory - Update documentation for new features
- Follow existing patterns for slash commands and events
This project is licensed under the MIT License - see the LICENSE file for details.
Jeffrey Milner
- Issues: GitHub Issues
- Community: Join the Official Discord Server