Introducing simply-xp 2

Every message
counts.

XP, level roles, rank cards and leaderboards for Discord bots and more. Rebuilt in TypeScript. Powered by your database. Simply remarkable.

npm install simply-xp better-sqlite3
bot.jsnode ≥ 14
const { connect, addXP, rankCard } = require("simply-xp");

await connect("./xp.sqlite", { type: "sqlite" });
await addXP(user.id, guild.id, 10, user.username);

const card = await rankCard(guild, user);
await channel.send({ files: [card] });
A rank card rendered by simply-xpA rank card rendered by simply-xp
What your members see

rankCard() · compareCard() · leaderboardCard()

Meet the cards.

Rank. Compare. Leaderboard. Each in two designs. Each one a single function call.

Dark rank card: avatar with rank badge 1 and a full level 69 bar over a near-black background with a violet glow
your-command.js
const { rankCard } = require("simply-xp");

const card = await rankCard(guild, user, {
  background: new URL("https://simplyxp.js.org/showcase/rank-background-dark.webp"),
  color: "#a0e8d8",
  lvlbar: "#ffffff",
  lvlbarBg: "#3a3650",
});
await channel.send({ files: [card] });

charts()

Thirty charts. One function.

Three types. Ten themes. Go ahead, try them all.

Bar chart, discord theme

type

theme · discord

const chart = await charts(guildId, { type: "bar", theme: "discord" });

quickstart

Four steps to your first level-up.

Install it. Connect it. Give XP. React.

terminalsimply-xp@2
npm install simply-xp better-sqlite3

# or, for MongoDB
npm install simply-xp mongodb

introducing v2

Not just Discord. Anywhere.

Rebuilt from the core up. In TypeScript.

  • Atomic. Every time.

    Every XP and level change is atomic, on both databases. Two updates to one user at once? Both count.

  • Your database. Your call.

    SQLite (better-sqlite3 7–13) or MongoDB (4–7). Install only the one you use.

  • Goodbye, discord.js.

    Functions take IDs and strings. One runtime dependency: @napi-rs/canvas.

  • Extend everything.

    Hook in with registerPlugins(). Listen with XpEvents.add(). Keep your data in Database.namespace().

The whole API 23 functions · 4 classes

benchmarks

9.5 MB. Not a typo.

That is the average with SQLite. 50 iterations of addXP(), setLevel(), rankCard(), compareCard(), charts() and leaderboardCard(). Memory is heapUsed + external of the Node.js process.

Average memory

SQLite9.5 MB
MongoDB34.5 MB

Average time per iteration

SQLite0.9 s
MongoDB2.4 s

Measured on an AMD Ryzen 9 9950X3D with DDR5-6400 on Ubuntu 26.04. MongoDB’s time includes network latency. Your numbers will vary with load, GC timing and configuration.

one more thing

Coming from v1? Shorter calls.

  • Functions take plain userId, guildId and username instead of a message or client.
  • Named imports: const { connect, addXP } = require("simply-xp").
  • rank() is rankCard(), roleSetup is LevelRoles, and fetch() returns position instead of rank.
  • The Migrate class moves old data across.
v1 → v2
- xp.rank(client, message, options);
+ xp.rankCard(guild, user, options);

- xp.leaderboard(client, guildId, limit);
+ xp.leaderboard(guildId, limit);

- xp.roleSetup.add(client, guildId, options);
+ xp.LevelRoles.add(guildId, options);

- xp.create(userId, guildId)
+ xp.create(userId, guildId, username)