BBotnexio

Buy now!

← All guides

Discord Level Bot: Set Up XP, Level Roles and a Leaderboard (2026)

Deutsche Version

Leveling turns "people who chat here sometimes" into "regulars". Members earn XP for activity, reach levels, unlock roles and compare themselves on a leaderboard. This guide walks through planning a leveling system and running it with your own self-hosted bot.

1. Decide what leveling is for

Before touching code, write down one goal:

  • Recognise regulars – level roles with a colour or a badge-style name.
  • Unlock channels – e.g. a "Level 5" role that can see a media channel (useful against drive-by spam).
  • Light competition – a leaderboard for the most active members.

Keep rewards cosmetic or access-based. Level roles should never be sold or tied to payments.

2. Plan your level roles

A simple ladder works better than twenty roles:

LevelRoleWhat it unlocks
1NewcomerBasic chat
5MemberMedia/links channel
15RegularVoice events, polls
30VeteranCosmetic colour

Create the roles in Discord first and place the bot's own role above them in Server Settings → Roles, otherwise the bot can't assign them.

3. Create your Discord application

  1. Open the Discord Developer Portal and create an application.
  2. Under Bot, create the bot and copy the token into your .env (never into Git).
  3. Under OAuth2, note the client ID and secret if you also want a web dashboard.
  4. Invite the bot with the bot and applications.commands scopes and the Manage Roles permission.

4. Understand the XP logic

Most level bots follow the same pattern: on each message, check a cooldown, add a little XP, compute the level, and assign a role when a threshold is crossed. A minimal sketch in discord.js v14:

client.on(Events.MessageCreate, async (msg) => {
  if (msg.author.bot || !msg.guild) return;
  const user = getUser(msg.guild.id, msg.author.id);      // your storage
  if (Date.now() - user.lastXp < 60_000) return;           // 1 XP tick per minute
  user.xp += 15 + Math.floor(Math.random() * 10);
  user.lastXp = Date.now();
  const level = Math.floor(0.1 * Math.sqrt(user.xp));
  if (level > user.level) {
    user.level = level;
    const roleId = levelRoles[level];                      // e.g. { 5: '123…' }
    if (roleId) await msg.member.roles.add(roleId);
  }
  saveUser(user);
});

The cooldown matters: without it, spam becomes the fastest way to level up.

5. Give members control

Good leveling respects members who don't want to be tracked. Offer an opt-out command, let people see and delete their stored data, and say in your welcome message what the bot stores.

Privacy is your job as operator. A level bot processes personal data of your members (Discord IDs, XP, activity times). If you run the bot, you are responsible for that data and for informing members before XP is collected, as well as for youth protection on your server. A bot can make this easier, but it cannot make your server compliant for you.

Shortcut: the Aramac Community Bot + Dashboard Starter

If you'd rather start from a complete codebase, the Aramac Community Bot + Dashboard Starter for Discord includes, according to its product page:

  • Leveling with level roles, /rank and /leaderboard
  • Welcome and goodbye messages with templates, auto-roles, self-roles via buttons (default) or reactions (reactions must be switched on with REACTION_ROLES=on)
  • /xp optout and /xp optin (opting out deletes the member's XP and stops tracking; only a small opt-out record – server ID, user ID, time – is kept, also after the member leaves, so the objection still applies if they rejoin; /xp optin removes it), /mydata export and /mydata delete, a /privacy notice with operator placeholders
  • A Next.js dashboard with Discord OAuth2 login (identify, guilds) that only shows servers you may manage – the dashboard never needs the bot token
  • DE/EN messages per server, Docker Compose (bot + dashboard), automated tests
  • discord.js 14.27, Node.js 22.13 or newer, SQLite via node:sqlite

Requirements: Node.js 22.13 or newer (or Docker), your own Discord application with bot token and OAuth2 client, and your own hosting. It contains no AI. For private and community servers only – not for shops, businesses or servers with paid memberships/roles. For consumers only. You run the bot and are the sole controller of the data it processes; you are also responsible for youth protection on your server.

29,00 € – Sold by Aramac GmbH · Price incl. VAT
Personal, non-commercial use only, for consumers only – see the licence.

FAQ

How much XP per message is normal? Many servers use 15–25 XP per message with a 60-second cooldown. Adjust after a week based on how fast people level.

Why doesn't the bot assign level roles? Usually the bot's role sits below the level roles, or it lacks Manage Roles.

Can members opt out of leveling? They should be able to. The Community Bot Starter has /xp optout and /xp optin. After an opt-out only an opt-out record is kept (also after the member leaves), so the objection still applies on rejoin.

Do I need a dashboard? No, but it lets moderators change settings without editing config files.

Can I use level roles for paid perks? Not with this starter: it is for non-commercial servers only, without paid memberships or roles.

Related guides

Not affiliated with Discord Inc. "Discord" is a trademark of Discord Inc.