djs-levels-dev
v0.2.4
Published
A simple to use leveling package for Discord.js
Downloads
6
Maintainers
Readme
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');
//Requiring the package
const Levels = require('djs-levels');
//IMPORTANT: MUST DO THIS STEP
Levels.connect('MONGODB URL HERE');
const client = new Discord.Client();
client.on('ready', () => {
console.log('Ready!')
});
//Must be async
client.on("message", async message => {
if (message.author.bot) return;
//A random amount of XP given when they send a message
const xpAmount = Math.floor(Math.random() * 9) + 1;
//Everytime they send a message, XP will be given to them.
const levelUp = await Levels.XP(message.author.id, message.guild.id, xpAmount)
//If they reach enough XP to level up, then a message will be sent.
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")