Discord bot for the Virtual Pinball Chat league - manages weekly competitions, high scores, playoffs, and leaderboards.
- Node.js 24
- discord.js 14
- @sapphire/framework
- @sapphire/plugin-subcommands
- MongoDB
-
Install dependencies:
npm install
-
Configure environment variables:
BOT_TOKEN- Discord bot tokenGUILD_ID- Discord server IDCOMMANDS_DIR- Path to commands directoryCONTEST_CHANNELS- Comma-separated list of channel IDs where contests are activeCOMPETITION_CHANNEL_NAME- Main competition channel nameHIGHSCORES_CHANNEL_NAME- High scores channel nameBOT_COMPETITION_ADMIN_ROLE_NAME- Role name for competition adminsBOT_HIGH_SCORE_ADMIN_ROLE_NAME- Role name for high score admins
-
Start the bot:
npm start
These commands are available to all users in the appropriate channels.
Post your score for the current weekly competition. Requires an attached screenshot.
!score 1234567
!score 1,234,567
!score 9876543 y # Also post to high scores channelPost a high score to a specific table. Requires an attached screenshot.
!high 5000000 medieval madness
!high 12345678 attack from marsDisplay the current weekly leaderboard for the competition.
/show-leaderboardShow your current score in the weekly competition.
/show-scoreDisplay the teams for the current team competition.
/show-teamsShow the current playoff bracket and standings.
/show-playoffsGenerate a random number between 1 and a specified maximum.
/generate-random-number max:100These commands require the Competition Admin or High Score Admin role.
Create a new weekly competition by VPS ID.
/create-week vpsid:xyz123 romrequired:true mode:classic
/create-week vpsid:xyz123 romrequired:false mode:default startdateoverride:2024-01-15 enddateoverride:2024-01-22| Parameter | Description |
|---|---|
| vpsid | VPS table ID |
| romrequired | Whether ROM is required |
| mode | Game mode (default, classic, etc.) |
| startdateoverride | Optional start date |
| enddateoverride | Optional end date |
| b2sidoverride | Optional B2S ID override |
| notes | Optional notes |
Edit the current week's settings.
/edit-current-week weeknumber:5 table:Medieval Madness mode:classicEdit a user's score in the current competition.
/edit-score username:PlayerName score:5000000Remove a score by rank from the current competition.
/remove-score rank:3Create a new season.
/create-season seasonnumber:5 seasonname:Spring 2024 seasonstart:2024-03-01 seasonend:2024-05-31Edit the current season's settings.
/edit-current-season seasonnumber:5 seasonname:Spring 2024 seasonstart:2024-03-01 seasonend:2024-05-31Display the season leaderboard.
/show-season-leaderboardCreate a new team for the current competition.
/create-team team:Team Alpha: player1, player2, player3Rename an existing team.
/edit-team-name current-team-name:Team Alpha new-team-name:Team OmegaRemove a team from the current competition.
/remove-team team:Team AlphaAuto-suggest balanced teams based on player history.
/suggest-teams messageId:123456789 numberOfWeeksToTotal:4 numberOfTeams:4 minTeamSize:3Create a new playoff from the current season leaderboard.
/create-playoffCreate a new playoff round.
/create-playoff-round roundName:Quarterfinals gameList:game1,game2,game3,game4Create a new high score table by VPS ID.
/create-high-score-table vpsid:xyz123Remove a specific high score entry.
/remove-high-score vpsid:xyz123 username:PlayerName score:5000000Search and display high scores for a table.
/show-table-high-scores tablesearchterm:medieval madness
/show-table-high-scores vpsid:xyz123Display the list of available high score tables.
/show-table-listCreate a placeholder message authored by the bot.
/create-messageRepin the competition corner pinned message.
/repin-messageRun a raffle for the current competition participants.
/run-raffleShow all available commands (admin only).
/show-commandsBuild and run with Docker Compose:
# From vpc-compose directory
docker-compose -f docker-compose-local.yml up -d --build vpc-bot
# View logs
docker-compose -f docker-compose-local.yml logs --tail=50 vpc-botThe project follows a modular structure within the src/ directory:
commands/: Contains various command handlers for user and admin interactions, categorized by function (e.g.,competition,highscores,teams,utility).lib/: Houses reusable logic and data handling, such as data pipelines, VPC/VPS data, and output formatting.listeners/: Handles Discord events and custom event listeners.preconditions/: Implements checks for command execution (e.g., channel restrictions, role requirements).services/: Contains core business logic, like database interactions (database.js).utils/: Provides utility functions for argument parsing, formatting, and logging.index.js: The main entry point for the application, responsible for initializing the Discord client, database connection, and logging in.
- Message commands use
!prefix (e.g.,!score) - Slash commands use
/prefix (e.g.,/show-leaderboard) - Commands with the
scorealias can use either!scoreor!post-score - Error messages auto-delete after 10 seconds
- Screenshots are required when posting scores