{"_id":"@cxstin/discord-levels","_rev":"6-4a9bee3f504a79415da679508f6880dc","name":"@cxstin/discord-levels","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@cxstin/discord-levels","version":"1.0.0","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"author":{"name":"Costin"},"license":"MIT","_id":"@cxstin/discord-levels@1.0.0","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"dist":{"shasum":"7f3752ac3daf39e45e701e7d032ad6611a7e1789","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.0.tgz","fileCount":14,"integrity":"sha512-0sjS1ajczAatmNtqNaXiSH/SmvfYaAJrj//zRZCjQPprM0OPReJ5U8a8BR72oH18QDacGIgnwQVAK8ObMHUPNw==","signatures":[{"sig":"MEYCIQDlt3J2/W5RYTh5lC8Eg93CF1iffL8Jlp1aZS+H2SwL/QIhAMY3DKFRNqEPUhP0RVMiR7ViiaIcyWi+4NmrxwEFYgM1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10795},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","scripts":{"build":"tsc"},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"_npmVersion":"10.8.1","description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","directories":{},"_nodeVersion":"20.16.0","dependencies":{"mongoose":"^8.13.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.14.0"},"_npmOperationalInternal":{"tmp":"tmp/discord-levels_1.0.0_1744560873049_0.6052895699794087","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@cxstin/discord-levels","version":"1.0.1","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"author":{"name":"Costin"},"license":"MIT","_id":"@cxstin/discord-levels@1.0.1","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"dist":{"shasum":"d516fdf1e01e797cc485ce81a2727e263e5bc141","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.1.tgz","fileCount":14,"integrity":"sha512-TeCf643tkF1Sb8FQThy6kQrN0xgUp3TrNaOzzkxCesshfGdsHsEs8B5kV/Y0CAG9dfwotnR51a2gyNGwzWx8lA==","signatures":[{"sig":"MEUCIDH8CTtvCcTuuohJw+K3MP4/xhs4fMivV0uy2CAAHZmpAiEAjax5DDkEeZzSwuHwaWtpzjkDQEXbQoMtAMCuCrcyF2Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10813},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","scripts":{"build":"tsc"},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"_npmVersion":"10.8.1","description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","directories":{},"_nodeVersion":"20.16.0","dependencies":{"mongoose":"^8.13.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.14.0"},"_npmOperationalInternal":{"tmp":"tmp/discord-levels_1.0.1_1744560951467_0.3192532218148194","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@cxstin/discord-levels","version":"1.0.2","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"author":{"name":"Costin"},"license":"MIT","_id":"@cxstin/discord-levels@1.0.2","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"dist":{"shasum":"5f1eb897b8b64d307ef099da8b13fcd1dcf70338","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.2.tgz","fileCount":14,"integrity":"sha512-7pWVxayDQYDppN80iIwr6IaQ3DB3bqdeavjsVgA0yDVGqJEmg1u/9HfVYJE7PNRZnB+RygOQxrL74uLP/xQEfg==","signatures":[{"sig":"MEYCIQDnTCt+VdX7BDwZguJ+874AI+n56Hpl3jdx0Q8FtCQSTAIhAPEW4MiNsCIuRf/XHblfLUjYCXFQqR4bY6V4+QcKfFrN","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10868},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","scripts":{"build":"tsc"},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"_npmVersion":"10.8.1","description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","directories":{},"_nodeVersion":"20.16.0","dependencies":{"mongoose":"^8.13.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.14.0"},"_npmOperationalInternal":{"tmp":"tmp/discord-levels_1.0.2_1744561266124_0.9301977169007274","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@cxstin/discord-levels","version":"1.0.3","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"author":{"name":"Costin"},"license":"MIT","_id":"@cxstin/discord-levels@1.0.3","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"dist":{"shasum":"011a40915ba6529c39b5004cd89144dfb0ca353e","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.3.tgz","fileCount":14,"integrity":"sha512-6kqoTjfY/lfdS/6Zu6R/KVTrNpUWbzVr1Xbm2AVwd2brpQeHsMPxYTLZoflgn680MucvIJtgEWpgA+6rzWYjVg==","signatures":[{"sig":"MEQCIDo//VYo3ZRLzwaKTJzXOoWTEwFAoqggaAV1qha3ihxeAiBiPM6BHN5ZkriNKv5qxu4BlLHNq4EByI2xvKGhvXnIiQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11262},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","scripts":{"build":"tsc"},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"_npmVersion":"10.8.1","description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","directories":{},"_nodeVersion":"20.16.0","dependencies":{"mongoose":"^8.13.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.14.0"},"_npmOperationalInternal":{"tmp":"tmp/discord-levels_1.0.3_1744751997520_0.6023277262068996","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@cxstin/discord-levels","version":"1.0.4","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"author":{"name":"Costin"},"license":"MIT","_id":"@cxstin/discord-levels@1.0.4","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"dist":{"shasum":"4804e3835cf143915570b7f829447875bd86ae1c","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.4.tgz","fileCount":14,"integrity":"sha512-S/8qf4vvR7rDos62THjzvSXMjvCMlRYPy4X04wLgmd46MkSMgZn6WzFPKFq8RY2AyfDdZqmYQTZYk0NHTSvWEg==","signatures":[{"sig":"MEUCIQCMyPKFExuA52t+K1XjUp3hYsXsWTXz01D3HKFsgmiz6wIgORYtNZ0FzH5t9uGt0sihN3GvBnn+kqDU1T88GRRqXCQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11316},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","scripts":{"build":"tsc"},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"_npmVersion":"10.8.1","description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","directories":{},"_nodeVersion":"20.16.0","dependencies":{"mongoose":"^8.13.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^22.14.0"},"_npmOperationalInternal":{"tmp":"tmp/discord-levels_1.0.4_1744753158896_0.5020528458240319","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@cxstin/discord-levels","version":"1.0.5","author":{"name":"Costin"},"description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","main":"dist/index.js","types":"dist/index.d.ts","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"license":"MIT","scripts":{"build":"tsc"},"devDependencies":{"@types/node":"^22.14.0","typescript":"^5.8.3"},"dependencies":{"mongoose":"^8.13.2"},"_id":"@cxstin/discord-levels@1.0.5","gitHead":"65e56ffcdf65b319278a7d900b89c723274652c7","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-+S+33HPqoCmFOkO6XOyCjIW9LINoFzJjvErj+cnIYjCE4InCxDSXuKY2KC0syCbsYaM2LPqAICvfuNtJZsRm4g==","shasum":"0da921b58ab06d87fbd44a71334ef10615dcbcf9","tarball":"https://registry.npmjs.org/@cxstin/discord-levels/-/discord-levels-1.0.5.tgz","fileCount":14,"unpackedSize":11328,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAEMFPTWFDmXfRlutVuFm9TkaAjQjSOvSAUVzyNGfrx0AiEA3Fsc8o4e6xQDZdoZM82TBw6vDFEJijogLvLks4gd+sY="}]},"_npmUser":{"name":"cxstin","email":"dobrecostindragos@gmail.com"},"directories":{},"maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/discord-levels_1.0.5_1744753288258_0.6881536441828529"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-13T16:14:32.960Z","modified":"2025-04-15T21:41:28.594Z","1.0.0":"2025-04-13T16:14:33.290Z","1.0.1":"2025-04-13T16:15:51.703Z","1.0.2":"2025-04-13T16:21:06.305Z","1.0.3":"2025-04-15T21:19:57.720Z","1.0.4":"2025-04-15T21:39:19.100Z","1.0.5":"2025-04-15T21:41:28.436Z"},"author":{"name":"Costin"},"license":"MIT","keywords":["xp","level","levelling system","discord.js","discord xp","discord","xp system"],"description":"A package that makes your life easier when it comes to making a leveling system for your discord.js bot!","maintainers":[{"name":"cxstin","email":"dobrecostindragos@gmail.com"}],"readme":"# Discord Levels\r\n- An easy to use xp framework made for discord bots that uses MongoDB!\r\n\r\n\r\n# Download\r\n\r\nYou can download it using any node package manager.\r\n\r\n## NPM\r\n```cli\r\nnpm install discord-levels\r\n```\r\n\r\n## Yarn\r\n\r\n```cli\r\nyarn add discord-levels\r\n```\r\n\r\n## PNPM\r\n\r\n```cli\r\npnpm add discord-levels\r\n```\r\n\r\n# Setting Up\r\n\r\nNow that you have the package downloaded, you can get started with setting it up!\r\n\r\nFirst, you need to import the module into your project.\r\n\r\n```js\r\nconst Levels = require('discord-levels')\r\n```\r\n\r\nAfter that, you need to create a new instance of the Levels class and provide a valid mongodb database url.\r\n\r\n```js\r\nconst levels = new Levels({ mongodbURL: \"mongodb://127.0.0.1\" })\r\n```\r\n\r\nTo start using the xp system, you need to run the init method\r\n\r\n```js\r\nlevels.init();\r\n```\r\n\r\n# Methods\r\n- Method arguments marked with a **?** are optional.\r\n\r\n### **getUser(userId: string, guildId?: string)** --> `UserLevelProfile`\r\n\r\nFetches the level profile of a user, or creates a new one if it doesn't exist.\r\n\r\n### **deleteUser(userId: string, guildId?: string)** --> `UserLevelProfile`\r\n\r\nDeletes the level profile of a user.\r\n\r\n### **getGuild(guildId: string)** --> `UserLevelProfile[]`\r\n\r\nFetches the level profiles of all users in a guild.\r\n\r\n### **deleteGuild(guildId: string)** --> `UserLevelProfile[]`\r\n\r\nDeletes the level profiles of all users in a guild.\r\n\r\n### **xpFor(level: number)** --> `number`\r\n\r\nReturns the amount of needed xp for a specific level.\r\n\r\n### **getLeaderboard(guildId: string, limit?: number)** --> `UserLevelProfile[]`\r\n\r\nFetches a specific amount of users in the guild and orders them from the highest to lowest level. \r\n\r\n## User Methods\r\n\r\n### **UserLevelProfile.setLevel(level: number)** --> `void`\r\n\r\nChanges the level of an user to a specific value.\r\n\r\n### **UserLevelProfile.addLevel(level: number)** --> `void`\r\n\r\nAdds a specific amount of levels to a user.\r\n\r\n### **UserLevelProfile.removeLevel(level: number)** --> `void`\r\n\r\nRemoves a specific amount of levels from a user.\r\n\r\n### **UserLevelProfile.setXP(xp: number)** --> `void`\r\n\r\nChanges the xp of an user to a specific value.\r\n\r\n### **UserLevelProfile.addXP(xp: number)** --> `void`\r\n\r\nAdds a specific amount of xp to a user.\r\n\r\n### **UserLevelProfile.removeXP(xp: number)** --> `void`\r\n\r\nRemoves a specific amount of xp from a user.\r\n\r\n### **UserLevelProfile.hasLevelledUp()** --> `boolean`\r\n\r\nReturns `true` if the user has reached a new level.\r\n\r\n# Examples\r\n\r\n### Add XP to a user when they send a message and check if the user has levelled up.\r\n```js\r\nconst { Client } = require('discord.js');\r\nconst Levels = require('discord-levels');\r\n\r\nconst client = new Client({ intents: [\"GuildMembers\", \"GuildMessages\"] });\r\nconst levels = new Levels({ mongodbURL: \"mongodb://127.0.0.1\" });\r\n\r\nlevels.init();\r\n\r\nclient.on(\"messageCreate\", async (message) => {\r\n    if (message.author.bot) return; // Return if the author of the message is a bot\r\n\r\n    const userLevelProfile = await levels.getUser(message.author.id, message.guild.id); // Fetch the user\r\n    const xpAmount = Math.floor(Math.random() * 35) + 15; // Get a random number from 15 to 35\r\n\r\n    userLevelProfile.addXP(xpAmount); // Add the XP to the user profile.\r\n\r\n    if (userLevelProfile.hasLevelledUp()) // Check if the user has levelled up\r\n        message.channel.send({ content: `Congrats, ${message.author}! You have advanced to level **${userLevelProfile.level}**!` })\r\n})\r\n\r\nclient.login(\"YOUR_TOKEN\");\r\n\r\n\r\n```","readmeFilename":"README.md"}