Skip to main content

Overview

The /xp command allows users to check their current experience points (XP) and level in the Faculty Bot system.

Parameters

This command takes no parameters.

Usage

/xp

Response

The bot will respond with an embed message showing:
  • Your current level
  • Your current XP amount
If you don’t have any XP yet, you’ll receive a message indicating you haven’t earned any XP.

Example Response (with XP)

You are level 5 with 1250 XP

Example Response (no XP)

You don't have any XP yet

Implementation Details

The command queries the database to retrieve your XP information:
let user = sqlx::query_as::<sqlx::Postgres, structs::UserXP>(
    "SELECT * FROM user_xp WHERE user_id = $1",
)
.bind(user_id)
.fetch_optional(pool)
.await
.map_err(Error::Database)?;

if let Some(user) = user {
    ctx.send(|f| {
        f.embed(|e| {
            e.description(lang.xp_msg(user.user_level, user.user_xp))
        });
        f
    })
    .await
    .map_err(Error::Serenity)?;
} else {
    ctx.send(|f| {
        f.embed(|e| e.description(lang.xp_msg_none()));
        f
    })
    .await
    .map_err(Error::Serenity)?;
}

Localization

This command supports multiple languages:
LanguageCommand NameDescription
English/xpShow your XP
German/xpZeige deine XP
Japanese/xp(Uses English as fallback)
The response messages are automatically localized based on your Discord client’s language setting.

Database Schema

The command queries the user_xp table:
SELECT * FROM user_xp WHERE user_id = $1
Table structure:
  • user_id: Discord user ID (bigint)
  • user_xp: Total experience points (integer)
  • user_level: Current level (integer)

How XP is Earned

XP is earned through various activities in the Discord server, such as:
  • Sending messages
  • Participating in events
  • Contributing to discussions
  • Other server-specific activities
(Note: XP earning mechanics are handled by other bot systems, not by this command)

Permissions

  • No guild restriction: This command can be used in servers or DMs
  • No special permissions required for users to run this command

Build docs developers (and LLMs) love