Overview
Theset-xp command allows administrators to manually adjust a user’s XP (experience points) value. The command automatically calculates and updates the corresponding level based on the XP amount.
Command Signature
Parameters
The Discord user whose XP you want to modify
The new XP value to set for the user (must be a positive integer)
Permissions Required
This command uses a custom permission check (executor_is_dev_or_admin) that requires one of:
- Semester Moderator Role (configured in bot settings)
- Staff Role (configured in bot settings)
- Administrator permission on Discord
Usage Examples
Set a user’s XP to 500
Reset a user’s XP to 0
Level Calculation
The bot automatically calculates the user’s level based on their XP using this formula:- 0-99 XP = Level 0
- 100-199 XP = Level 1
- 500-599 XP = Level 5
- 1000-1099 XP = Level 10
Implementation Details
Source reference:src/commands/administration.rs:114-172
Database Operations
The command performs the following operations:- Checks if the user exists in the
user_xptable - If the user exists: Updates their XP and recalculates their level
- If the user doesn’t exist: Creates a new entry with the specified XP and calculated level
SQL Queries
Update existing user:Use Cases
- Correcting XP after a bug or error
- Rewarding users for special contributions
- Resetting XP as part of a moderation action
- Setting up test accounts with specific XP levels