djs-levels
v0.1.5
Published
A simple to use leveling package for Discord.js
Downloads
4
Maintainers
Readme
Table of Contents
About
djs-levels is a simple to use leveling system for discord.js.
Changelog
Soon there will be added a Leaderboard system!
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 djsLevels = require('djs-levels');
//IMPORTANT: MUST DO THIS STEP
djsLevels.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 hasLevelUp = await djsLevels.XP(message.author.id, message.guild.id, xpAmount)
//If they reach enough XP to level up, then a message will be sent.
if (hasLevelUp) {
const user = await djsLevels.find(message.author.id, message.guild.id);
message.channel.send(`Great job ${message.author}. You have just advanced to level ${user.level}!`);
}
})
client.login("TOKEN")