Repository navigation
v2.0.0
🚀 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.jsandmongooserequirements. Plain IDs and strings (userId,guildId,username) are now used instead ofmessageorclient. - Changed imports. Moved from default imports to named exports (
const { connect, addXP, fetch } = require("simply-xp")). - Replaced
rank()withrankCard(). Uses a new options shape and takes plain objects instead of a discord.jsMessage. - Replaced
roleSetupandlvlRole()with theLevelRolesclass. Use methods likeLevelRoles.add()andLevelRoles.getUserRoles(). - Changed
fetch()andleaderboard()return shapes.rankis nowposition, and fields likereqxp,shortxp, andshortreqhave been removed. - Updated
create(). Now requires a username:create(userId, guildId, username). - Streamlined
charts(). Droppedline,radar, andpolarAreacharts, keeping onlybar,doughnut, andpiewith 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"toconnect()alongside installingbetter-sqlite3. - Added
compareCard()andleaderboardCard(). New card renderers for head-to-head comparisons and ranked image lists. - Added
XpEvents. A shared event emitter replacing discord.js for trackinglevelUp,levelDown,info,warn,error, anddebug. - 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
Migrateclass. Move data between MongoDB and SQLite, or import fromdiscord-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(), andleaderboard()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
finallyblock. - 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()andaddLevel()reporting bugs. Brand new users now correctly save and return accurate records. - Fixed
setXP()throwing errors on new users. BothsetXP()andsetLevel()now support automatic user creation consistently. - Fixed
setLevel()event triggers.levelUpevents 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