Starts with a message

Levels and leaderboard

Every message earns a little XP, and level-ups are announced in #levels. /rank shows a member how far the next level is, and /leaderboard shows who has been around the most.

Illustration. The real interface may look different.

How it works

  1. Every message a member sends adds a little XP to their score.

  2. When the score reaches a new level, the bot announces it in your levels channel.

  3. /rank shows a member their level and progress. /leaderboard lists the top members, page by page.

How to make a level system on Discord

One flow hands out XP, two commands read it back. Everything lives in two numbers per member, so the build stays small even on a large server.

Describe it to your AI assistant

I want our regulars to get something for being active. Build a level module: give members 15 XP per message, at most once a minute, and announce level-ups in #levels. Add /rank that shows a member their level, their place on the server and a progress bar to the next level. Add /leaderboard that posts the ranking in pages of ten with Previous and Next buttons. Make the XP per message and the channel settings.

Copy it and swap in your own channel and role names. Your assistant has a tested version of this example to start from.

Build it in the editor

Start with the XP flow on a "Message created" trigger, then add /rank and /leaderboard. In the "Create new flow" dialog, "Start from a template" offers "XP system", which has the XP flow, the level-up post and both commands in a simpler form.

The 3 flows, step by stepStep names are the ones the editor shows.

Flow 1XP per message

Trigger: Message createdany message from a member, bots ignored, with a one-minute cooldown per member.

  1. Increase a stored numberAdds your XP per message to the member's total.
  2. Square rootTurns the total into a level. The tested version takes the square root of XP divided by 100.
  3. Greater thanCompares that with the level the member was last announced at.
  4. Store a valueSaves the new level.
  5. Call another flowRuns the announce flow, which posts the level-up in your announcement channel.

Flow 2/rank

Trigger: Slash command/rank.

  1. Get rank of a stored valueFinds the member's place among everyone with XP.
  2. Read a stored valueReads their XP total.
  3. Render progress barDraws the bar toward the next level as text, with no image involved.
  4. Create messageBuilds the reply.
  5. Reply to interactionAnswers the command.

Flow 3/leaderboard

Trigger: Slash command/leaderboard.

  1. Format leaderboard pagesSorts all members by XP and cuts the list into pages.
  2. Send paginated messagePosts the pages as one message with Previous and Next buttons.
  3. Reply to interactionAnswers the command.

Test it, change it

What it stores

  • XPPer userThe total per member.
  • LevelPer userThe level each member was last announced at, so a level-up is posted once.

How to test it

  1. Open a flow in the editor and click "Test run". Choose the member under "Run as" and click "Run test". The run uses your real server data but sends, changes and deletes nothing, and shows what each step would have done.
  2. A new flow is a "Draft" and does not run in Discord. Switch it on and click "Save & activate".
  3. Write two messages within a minute and check under "Stored data" that only the first one counted. For a quick level-up, raise the XP per message for the test and lower it again afterwards.
  4. Each real run then shows up under "Executions", with the reason if it failed or was skipped.

What to change

XP per message
A setting in the module's "Configuration" tab.
Channel
The announcement channel is a setting. You can also limit XP to one channel.
Cooldown
The "Cooldown" on the trigger of the XP flow. One minute is a fair default against spam.
Level curve
The two math steps after the XP is added. A smaller divisor means faster levels.

Watch out for

  • The message trigger needs the Message Content Intent, switched on for your bot in the Discord Developer Portal. The editor shows a badge on the trigger.
  • By default only the member who ran /leaderboard can flip its pages, and the buttons stop working after 24 hours. Both are options on "Send paginated message".
  • Members who left keep their XP in storage. Delete their rows under "Stored data" if the leaderboard should only show current members.

Questions about this build

Can members get a role at a certain level?

Yes. In the XP flow, after the new level is saved, add "If" for the level you want and "Add role to member". The bot's role has to sit above the role it gives.

How do I stop spam from farming XP?

The cooldown on the trigger counts one message per member per minute, however many they send. You can also limit XP to a few channels in the trigger settings.

Should I build this or use the bot's level module?

If you want levels today, with XP for voice time and role rewards, switch on the level module that comes with your bot. Build your own when you need rules the module does not have.

Vuoi il tuo server nella beta?

La V3 è un sistema vasto e in continua evoluzione, quindi i server entrano uno alla volta e non tutti insieme. Ogni candidatura viene letta da una persona e ricevi una risposta entro pochi giorni.

I server già nella beta decidono buona parte di ciò che costruiamo dopo. Ciò che crei resta tuo: flow e moduli restano anche quando la beta finisce.