XP & Leveling¶
XP & Leveling is an engagement system that rewards active community members for their participation. By sending messages in designated channels, users earn experience points (XP) that contribute to their overall level. As users reach new milestones, Tux can automatically assign them roles, creating a clear path for progression and recognition within the server.
The system is designed to be fair and resistant to spam, using a cooldown mechanism and configurable exponents to control the pace of leveling. It also supports multipliers, allowing you to reward specific groups like server boosters or contributors with faster progression.
How It Works¶
Mechanics¶
The leveling system tracks user activity and calculates levels based on total accumulated XP.
- XP Calculation: XP is awarded for each message sent, provided the user is not on cooldown.
- Level Formula: Your level is calculated from total XP using an exponential formula:
level = (total_xp / 100) ^ (1 / exponent). - Cooldowns: To prevent spam, users only earn XP once every few seconds (configurable).
- Multipliers: Roles can be assigned multipliers (e.g., 1.1x) that increase the amount of XP earned per message.
Automation¶
Tux handles the entire lifecycle of user progression:
- Automatic Assignment: When a user reaches a level milestone defined in the configuration, Tux instantly assigns the corresponding role.
- Role Management: The bot can be configured to manage these roles as users progress, ensuring they always have the correct rank.
- Background Tracking: All XP gains and level calculations happen in real-time as users chat.
Triggers¶
The feature activates when:
- A user sends a message in a channel that is not blacklisted.
- A user's total XP reaches the threshold for the next level.
User Experience¶
What Users See¶
Leveling is designed to be rewarding but non-intrusive:
- Silent Progression: XP is awarded silently without notification messages.
- Status Checks: Users can check their current level and progress using the
/levelcommand. - Role Rewards: New roles appear on the user's profile automatically as they reach level milestones.
- Leaderboards: Users can see how they rank against others using the
/levelscommand.
Interaction¶
Users interact with this feature by:
- Chatting in the server's public channels.
- Using
/levelto view their personal progress. - Using
/levelsto view the server leaderboard.
Configuration¶
Leveling is configured through the server's config.json file.
Configuration Options¶
| Option | Type | Default | Description |
|---|---|---|---|
XP_COOLDOWN |
integer |
1 |
Seconds required between messages to earn XP. |
LEVELS_EXPONENT |
float |
2.0 |
The exponent used in the level calculation formula. |
XP_BLACKLIST_CHANNELS |
array |
[] |
List of channel IDs where users cannot earn XP. |
XP_ROLES |
array |
[] |
List of level milestones and their associated role IDs (level, role_id). |
XP_MULTIPLIERS |
array |
[] |
Role-based multipliers (role_id, multiplier) to boost XP gain. |
SHOW_XP_PROGRESS |
boolean |
true |
Show XP progress in level/leaderboard output. |
ENABLE_XP_CAP |
boolean |
false |
Enable an XP cap. |
Example Configuration¶
{
"XP_CONFIG": {
"XP_COOLDOWN": 1,
"LEVELS_EXPONENT": 1.75,
"XP_BLACKLIST_CHANNELS": [123456789012345678],
"XP_ROLES": [
{ "level": 5, "role_id": 111222333444555666 },
{ "level": 10, "role_id": 222333444555666777 }
],
"XP_MULTIPLIERS": [
{ "role_id": 555666777888999000, "multiplier": 1.1 }
]
}
}
Configuration Guide
For detailed configuration instructions, see the Admin Guide.
Commands¶
This feature provides the following commands for users and administrators:
| Command | Description | Documentation |
|---|---|---|
/level |
View your current level, XP, and progress. | Details |
/levels |
View the server-wide XP leaderboard. | Details |
/levels set |
Set a user's level (Admin only). | Details |
/levels reset |
Reset a user's XP and level (Admin only). | Details |
Permissions¶
Bot Permissions¶
Tux requires the following permissions for this feature:
- Read Messages - Needed to track user activity.
- Manage Roles - Needed to assign roles at level milestones.
- Send Messages - Needed to respond to level and leaderboard commands.
User Permissions¶
None required for basic usage. Administrator commands require appropriate permissions.
Permission System
Configure command permissions via /config commands or see the Permission Configuration guide.
Troubleshooting¶
Issue: Users are not gaining XP¶
Symptoms:
- The
/levelcommand shows no increase in XP after sending messages.
Causes:
- The channel is in the
XP_BLACKLIST_CHANNELSlist. - The user is sending messages faster than the
XP_COOLDOWNsetting allows. - The user has been manually blacklisted from the XP system.
Solutions:
- Check the channel blacklist in your configuration.
- Verify that the user is not sending messages during the cooldown period.
- Use
/levels blacklistto check the user's status.
Issue: Roles are not being assigned¶
Symptoms:
- A user reaches a level milestone but does not receive the associated role.
Causes:
- Tux is missing the "Manage Roles" permission.
- The role to be assigned is positioned above Tux's highest role in the Discord settings.
- The
XP_ROLESconfiguration has an incorrect role ID.
Solutions:
- Ensure Tux has "Manage Roles" permission.
- Move Tux's role above the leveling roles in the server hierarchy.
- Double-check the role IDs in your
config.json.
Limitations¶
- Message Content: XP is currently awarded per message, regardless of message length or content quality.
- One Server Focus: Leveling data is specific to each server and does not carry over between servers.
- Role Hierarchy: Tux cannot assign roles that are higher than its own role in the Discord hierarchy.