Overview
The/leaderboard command displays the top 10 users in the server ranked by their experience points (XP). This allows you to see who the most active and engaged members are.
Parameters
This command takes no parameters.Usage
Response
The bot will respond with an embed message titled “Leaderboard” showing:- Rank (1-10)
- Discord username
- Total XP for each user
Example Response
Implementation Details
The command queries the database to retrieve the top 10 users by XP:Username Formatting
The command handles Discord’s username system changes (“Pomelo” update):- Users with the legacy discriminator
#0000have it removed from display - Usernames are shown in their tag format
Localization
This command supports multiple languages:| Language | Command Name | Description |
|---|---|---|
| English | /leaderboard | Show the Top 10 users by XP |
| German | /leaderboard | Zeige die besten 10 Nutzer anhand ihrer XP |
| Japanese | /leaderboard | (Uses English as fallback) |
Database Schema
The command queries theuser_xp table:
user_id: Discord user ID (bigint)user_xp: Total experience points (integer)user_level: Current level (integer)
Permissions
- No guild restriction: This command can be used in servers or DMs
- No special permissions required for users to run this command
Performance Considerations
The leaderboard command:- Fetches only the top 10 users (not the entire database)
- Uses efficient SQL ordering with
ORDER BY user_xp DESC LIMIT 10 - Makes individual Discord API calls to fetch user information for each of the 10 users
Related Commands
/xp- View your own XP and level
Notes
- The leaderboard shows active users who have earned XP through server participation
- If fewer than 10 users have earned XP, the leaderboard will show only those users
- XP is earned through various activities in the server (see the
/xpcommand documentation for more details)