Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

djs-levels-dev

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djs-levels-dev

A simple to use leveling package for Discord.js

  • 0.2.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Table of Contents

  • About

  • Changelog

  • Installation

  • Example-Usage

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")

Keywords

FAQs

Package last updated on 30 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc