rankCard() · compareCard() · leaderboardCard()
Meet the cards.
Rank. Compare. Leaderboard. Each in two designs. Each one a single function call.

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] });const { rankCard } = require("simply-xp");
// guild: { id, name }
// user: { id, username, avatarURL }
// the default card
const card = await rankCard(guild, user);
await channel.send({ files: [card] });const { rankCard } = require("simply-xp");
const card = await rankCard(guild, user, { legacy: true });
await channel.send({ files: [card] });const { compareCard } = require("simply-xp");
const card = await compareCard(guild, user1, user2);
await channel.send({ files: [card] });const { compareCard } = require("simply-xp");
const card = await compareCard(guild, user1, user2, { light: true });
await channel.send({ files: [card] });const { leaderboard, leaderboardCard } = require("simply-xp");
const top = await leaderboard(guildId, 6);
const card = await leaderboardCard(top, {}, {
name: "Development Hub",
imageURL: guildIconURL,
memberCount: 20,
});const { leaderboard, leaderboardCard } = require("simply-xp");
const top = await leaderboard(guildId, 6);
const card = await leaderboardCard(top, { light: true }, guildInfo);charts()
Thirty charts. One function.
Three types. Ten themes. Go ahead, try them all.

type
theme ·
const chart = await charts(guildId, { type: "bar", theme: "discord" });quickstart
Four steps to your first level-up.
Install it. Connect it. Give XP. React.
npm install simply-xp better-sqlite3
# or, for MongoDB
npm install simply-xp mongodbconst { connect } = require("simply-xp");
await connect("./xp.sqlite", { type: "sqlite" });
// or MongoDB
await connect(process.env.MONGO_URI, { type: "mongodb" });const { addXP, fetch } = require("simply-xp");
const result = await addXP(userId, guildId, { min: 10, max: 25 }, username);
if (result.levelDifference > 0)
console.log(`${username} levelled up to ${result.level}!`);
const user = await fetch(userId, guildId);
console.log(
`${user.name}: level ${user.level}, ${user.xp} XP, rank #${user.position}`,
);const { LevelRoles, XpEvents } = require("simply-xp");
await LevelRoles.add(guildId, { level: 5, roles: [roleId] });
// add() keeps other listeners; on() replaces them
const stop = XpEvents.add({
levelUp: (user, newRoles) => {
console.log(`${user.name} reached level ${user.level}!`);
// newRoles are the role IDs LevelRoles has set for this level
},
});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-sqlite37–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 inDatabase.namespace().
The whole API 23 functions · 4 classes
Store and read
Change XP and levels
Render images
Roles, events and plugins
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.
one more thing
Coming from v1? Shorter calls.
- Functions take plain
userId,guildIdandusernameinstead of amessageorclient. - Named imports:
const { connect, addXP } = require("simply-xp"). rank()isrankCard(),roleSetupisLevelRoles, andfetch()returnspositioninstead ofrank.- The
Migrateclass moves old data across.
- 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)