A Discord bot written in Rust that implements a community scoring and trading system. Users can earn points through reactions (+2/-2), trade points with each other, and purchase items from a shop using their accumulated points.
RustBot is a feature-rich Discord bot that gamifies community interaction through a scoring system. Users receive points when others react to their messages with +2 emojis, and lose points with -2 emojis. The bot tracks scores in a SQLite database and provides commands for leaderboards, trading points, and a shop. It also supports image rotation (including automatic rotation on some messages), RuneScape Grand Exchange price lookups with custom aliases, and admin utilities.
- serenity (0.12.4) - Discord API library for Rust, providing client, gateway, and framework functionality
- poise (0.6.1) - Discord command framework built on top of Serenity
All commands use the ! prefix.
!score- Shows the current score of the command caller. Can also be used as a reply to another user's message to see their score.!top- Displays the top scoring user.!leader(aliases:!board,!leaderboard,!lb) - Displays the top 10 scoring users.!wallet(aliases:!balance,!bank) - Shows the user's current balance of +2 emojis.
!trade <user> <amount>- Trades the specified amount of +2 emojis from the command caller to the specified user. The trade affects both users' scores (giver loses 2 points per +2, receiver gains 2 points per +2). Validates that the caller has sufficient balance before executing.
!shop(alias:!store) - Displays the shop with all available items, their prices, and descriptions.!shop buy <symbol>- Purchases an item from the shop using the item's symbol. Validates that the user has enough +2 emojis to make the purchase.
!count <symbol>(aliases:!itemCount,!getCount) - Shows the current count of a specific shop item.
!rotate- Rotates an image 180°. Use as a reply to a message that has an image attachment (PNG or JPEG). The bot may also automatically rotate images on messages in some channels.
!grand_exchange <item>(aliases:!price,!ge,!rsge,!rsprice) - Fetches the current Grand Exchange price for an item. Supports aliases fromge_set_alias.!grand_exchange_history <item>(aliases:!priceHistory,!ph,!history,!hst) - Fetches price history for an item.!ge_set_alias <alias> <item>(aliases:!ge-alias,!gealias,!gea) - Sets a custom alias for an item name when querying GE prices.!lookup_alias <alias>(aliases:!ge-lookup-alias,!lookup,!?,!alias,!what) - Looks up which item an alias maps to.
!smash- Returns a random "Smash" or "Pass" response. Used as a reply to messages.!judge- Judges a post by adding a random +2 or -2 reaction. Must be used as a reply to another message. Prevents duplicate judgments on the same post. Note: Marked for rework.
!help [command]- Displays the help menu. If a command name is provided, shows detailed help for that specific command.
- Reaction-based Scoring: Automatically tracks scores when users react with +2 or -2 emojis
- Database Persistence: Uses SQLite to store user scores, trade logs, shop data, and GE aliases
- Trade System: Users can trade +2 emojis with each other, affecting their scores
- Shop System: Virtual economy where users can purchase items using accumulated +2 emojis
- Leaderboards: Track top performers in the community
- Image Rotation: Rotate images 180° via
!rotate(reply to an image) or automatically on messages with image attachments - RuneScape Grand Exchange: Look up item prices and history; custom aliases for item names
- Migration Support: Database migrations managed through sqlx-cli
- CI: Format/lint (rustfmt, clippy), version-bump check on PRs, and Docker build
This project uses pre-commit hooks to ensure code quality before commits. To set up:
-
Install pre-commit (requires Python):
pip install pre-commit
-
Install the git hooks:
pre-commit install
-
The hooks will now run automatically on every commit, checking:
- rustfmt: Code formatting with
cargo fmt - clippy: Linting with
cargo clippy
- rustfmt: Code formatting with
To manually run the hooks:
pre-commit run --all-filesTo skip hooks for a single commit (not recommended):
git commit --no-verifycargo sqlx migrate run --database-url sqlite:data/rustbot.sqlite --source data/migrations