Table of Contents
About
djs-levels is a simple to use leveling system for discord.js.
Changelog
Version 2.0 now introduces a Leaderboard system.
You're now able to show when people level up what rank they are in the server & also a full on leaderboard of all the top users in your server!
Installation
In order to use djs-levels
please make sure you have Node 12.0.0 or later installed.
Please also make sure you have mongoose and MongoDB.
To install djs-levels
you can simply do
npm install djs-levels
And to update djs-levels
you can run
npm update djs-levels
Example
const Discord = require('discord.js');
const Levels = require('djs-levels');
Levels.connect('MONGODB URL HERE');
const client = new Discord.Client();
client.on('ready', () => {
console.log('Ready!')
});
client.on("message", async message => {
if (message.author.bot) return;
const xpAmount = Math.floor(Math.random() * 9) + 1;
const levelUp = await Levels.XP(message.author.id, message.guild.id, xpAmount)
if (levelUp) {
const user = await Levels.find(message.author.id, message.guild.id);
message.channel.send(`Congrats ${message.author}, you just advanced to level ${user.level}!`);
}
})
client.login("TOKEN")