Skip to content

v2.0.0

Choose a tag to compare

@Abadima Abadima released this 06 Sep 04:12
· 17 commits to latest since this release
bffacf3

🚀 simply-xp v2.0.0

This is a complete rewrite of simply-xp transitioning to TypeScript and a more modular architecture, with a focus on improved performance, better error handling, and more flexible database support. I've also removed discord.js as a dependency, making the library simply more flexible!


🛑 Breaking Changes

  • Dropped discord.js and mongoose requirements. Plain IDs and strings (userId, guildId, username) are now used instead of message or client.
  • Changed imports. Moved from default imports to named exports (const { connect, addXP, fetch } = require("simply-xp")).
  • Replaced rank() with rankCard(). Uses a new options shape and takes plain objects instead of a discord.js Message.
  • Replaced roleSetup and lvlRole() with the LevelRoles class. Use methods like LevelRoles.add() and LevelRoles.getUserRoles().
  • Changed fetch() and leaderboard() return shapes. rank is now position, and fields like reqxp, shortxp, and shortreq have been removed.
  • Updated create(). Now requires a username: create(userId, guildId, username).
  • Streamlined charts(). Dropped line, radar, and polarArea charts, keeping only bar, doughnut, and pie with built-in color themes.
  • Removed auto_purge. Leaderboard reads no longer silently delete user records not found in member caches.

✅ Additions

  • SQLite support. Pass type: "sqlite" to connect() alongside installing better-sqlite3.
  • Added compareCard() and leaderboardCard(). New card renderers for head-to-head comparisons and ranked image lists.
  • Added XpEvents. A shared event emitter replacing discord.js for tracking levelUp, levelDown, info, warn, error, and debug.
  • Added registerPlugins() / unregisterPlugins(). A lightweight plugin system with lifecycle hooks and version matching.
  • Added Database.namespace(). A private key/value store for plugins to persist data.
  • Added Migrate class. Move data between MongoDB and SQLite, or import from discord-xp.
  • Added setFlags() and global leaderboards. Tag user records and rank users across every guild in the database at once.

⚡ Improvements

  • Atomic database operations. Every XP/level mutation is now a single atomic operation, preventing race conditions and silent XP loss.
  • Database-side sorting. fetch(), rankCard(), and leaderboard() now utilize database-side counting instead of loading every user into memory.
  • Configurable xp_rate. Easily set to "slow", "normal", "fast", or a custom multiplier.
  • Memory leak fixes. Card renderers safely release their canvas cache in a finally block.
  • Full TypeScript definitions. Generated directly from source to prevent typing drift.

🐛 Bug Fixes

  • Fixed cross-guild data bugs. Unique indexes are now enforced on the (guild, user) pair instead of just the user ID.
  • Fixed addXP() and addLevel() reporting bugs. Brand new users now correctly save and return accurate records.
  • Fixed setXP() throwing errors on new users. Both setXP() and setLevel() now support automatic user creation consistently.
  • Fixed setLevel() event triggers. levelUp events now only fire when levels genuinely change.
  • Fixed reset() reporting false success. Now properly checks if records exist in the database before resetting.
  • Fixed connect() async handling. connect() now properly awaits verified database connections before resolving.

Full Reference: https://simplyxp.js.org/docs/intro/

Full Changelog: v1.3.8...v2.0.0