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
Every message a member sends adds a little XP to their score.
When the score reaches a new level, the bot announces it in your levels channel.
/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.
- Increase a stored numberAdds your XP per message to the member's total.
- Square rootTurns the total into a level. The tested version takes the square root of XP divided by 100.
- Greater thanCompares that with the level the member was last announced at.
- Store a valueSaves the new level.
- Call another flowRuns the announce flow, which posts the level-up in your announcement channel.
Flow 2/rank
Trigger: Slash command/rank.
- Get rank of a stored valueFinds the member's place among everyone with XP.
- Read a stored valueReads their XP total.
- Render progress barDraws the bar toward the next level as text, with no image involved.
- Create messageBuilds the reply.
- Reply to interactionAnswers the command.
Flow 3/leaderboard
Trigger: Slash command/leaderboard.
- Format leaderboard pagesSorts all members by XP and cuts the list into pages.
- Send paginated messagePosts the pages as one message with Previous and Next buttons.
- 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
- 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.
- A new flow is a "Draft" and does not run in Discord. Switch it on and click "Save & activate".
- 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.
- 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.
More examples
Vill du ha in din server i betan?
V3 är ett stort system och det utvecklas fortfarande snabbt, så servrar släpps in en i taget i stället för alla på en gång. Varje ansökan läses av en person och du får svar inom några dagar.
Servrarna som redan är med i betan avgör en stor del av vad vi bygger härnäst. Det du bygger är ditt: flows och moduler finns kvar när betan tar slut.