npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@elaraa/discord-xp

v1.0.0

Published

A package to make Discord leveling system much more easier!

Downloads

2

Readme

Installation

To install the package, you can easily do it by typing the command below:

+ npm install @elaraa/discord-xp@latest

To update to the latest version to our package, just do

+ npm update @elaraa/discord-xp

If you need help or you encountered an error while using our package, feel free to join our Discord server and we'll try to assist as soon as possible!

Changelogs

// Updates coming soon!

Starting up

To start using this package, you will need to do these two steps first.

  • You will need to require the package using the example code below:
const Xp = require('@elaraa/discord-xp')

After that you can now connect to your Mongoose database. Put this below the line where you imported the package

Xp.connect('mongodb://...');

Functions

• createUser — Creates a new user on the database if it doesn't exist.

Xp.createUser(<UserID - String>, <GuildID - String>)

• deleteUser — Remove all the data of a user in the database if data exist.

Xp.deleteUser(<UserID - String>, <GuildID - String>)

• deleteGuild — Deletes all the data of the server in the database.

Xp.deleteGuild(<GuildID - String>)

• resetGuild — Resets all the settings for the guild in the database (XP will not reset)

Xp.resetGuild(<GuildID - String>)

• fetchLeadboard — Fetches the leaderboard from the guild Id provided

Xp.fetchLeadboard(<GuildID - String>, <Ranks - Number>)

• fetchUser — Fetch an individual user from the database

Xp.fetchUser(<UserID - String>, <GuildID - String>)

• xpFor — Calculate how many XP needed for a level

Xp.xpFor(<Level - Number>)

• xpLevel — Calculate how many levels is equal to the XP given.

Xp.xpLevel(<XP - Number>)

• setXp — Set the user's XP manually

Xp.setXp(<UserID - String>, <GuildID - String>, <XP - Number>)

• setLevel — Set the user's level manually

Xp.setLevel(<UserID - String>, <GuildID - String>, <Level - Number>)

• addXp — Add XP to the given user

Xp.addXp(<UserID - String>, <GuildID - String>, <XP - Number>)

• addLevel — Add level to the given user

Xp.addLevel(<UserID - String>, <GuildID - String>, <Level - Number>)

• subtractXp — Subtract the XP from the user's current XP

Xp.addXp(<UserID - String>, <GuildID - String>, <XP - Number>)

• subtractLevel — Subtract the level from the user's current level

Xp.subtractLevel(<UserID - String>, <GuildID - String>, <Level - Number>)

• cdAppend — Add a random XP to a user every minute only (Suggested for Leveling System)

Xp.cdAppend(<UserID - String>, <GuildID - String>, <MinimumXP - Number>, <MaximumXP - Number>)

• disableGuildXp — Disable XP system to the guild if enabled

Xp.disableGuildXp(<GuildID - String>)

• disableUserXp — Disable XP system to a specific user on a guild if enabled

Xp.disableUserXp(<UserID - String>, <GuildID - String>)

• enableGuildXp — Enable XP system to the Guild if disabled

Xp.enableGuildXp(<GuildID - String>)

• enableUserXp — Enable XP system to a specific user on a guild if disabled

Xp.enableUserXp(<UserID - String>, <GuildID - String>)

Example Usage

import { Client } from "discord.js";
const client = new Client({ intents: 3276799 });
const Xp = require('@elaraa/discord-xp')

xp.connect("mongodb://...").then(() => {
  console.log("Connected to database");
});

client.on("ready", () => {
  console.log("I am ready!");
});

client.on("messageCreate", (message) => {

  const prefix = "!";
  const args = message.content.slice(prefix.length).split(/ +/);
  const command = args.shift().toLowerCase();

  if (message.author.bot || !message.content.startsWith(prefix)) return;

  xp.cdAppend(message.author.id, message.guildId, 5, 20)
    .then((msg) => {
      if (msg === "LevelUp") {
        message.channel.send({ content: "You have leveled up!" });
      }
    })
    .catch((err) => console.log("Error appending xp: " + err));

});

client.login(token);

Level Data

The current version of this package uses the XP system to determine on how much XP the user will need in order to level up. You can use the following formula to calculate how much XP you need to level up: 6 * (lvl ** 2) + (55 * lvl) + 100 - xp where lvl is your current level, and xp is how much XP you already have.

| Level | XP needed to level up | Total XP required | |----------- |-----------------------------|-----------------------------| | 1 | 161 | 161 | | 2 | 234 | 468 | | 3 | 319 | 957 | | 4 | 416 | 1664 | | 5 | 525 | 2625 | | 6 | 646 | 3876 | | 7 | 779 | 5453 | | 8 | 924 | 7392 | | 9 | 1081 | 9729 | | 10 | 1250 | 12500 | | 11 | 1431 | 15741 | | 12 | 1624 | 19488 | | 13 | 1829 | 23777 | | 14 | 2046 | 28644 | | 15 | 2275 | 34125 | | 16 | 2516 | 40256 | | 17 | 2769 | 47073 | | 18 | 3034 | 54612 | | 19 | 3311 | 62909 | | 20 | 3600 | 72000 | | 21 | 3901 | 81921 | | 22 | 4214 | 92708 | | 23 | 4539 | 104397 | | 24 | 4876 | 117024 | | 25 | 5225 | 130625 | | 26 | 5586 | 145236 | | 27 | 5959 | 160893 | | 28 | 6344 | 177632 | | 29 | 6741 | 195489 | | 30 | 7150 | 214500 | | 31 | 7571 | 234701 | | 32 | 8004 | 256128 | | 33 | 8449 | 278817 | | 34 | 8906 | 302804 | | 35 | 9375 | 328125 | | 36 | 9856 | 354816 | | 37 | 10349 | 382913 | | 38 | 10854 | 412452 | | 39 | 11371 | 443469 | | 40 | 11900 | 476000 | | 41 | 12441 | 510081 | | 42 | 12994 | 545748 | | 43 | 13559 | 583037 | | 44 | 14136 | 621984 | | 45 | 14725 | 662625 | | 46 | 15326 | 704996 | | 47 | 15939 | 749133 | | 48 | 16564 | 795072 | | 49 | 17201 | 842849 | | 50 | 17850 | 892500 | | 51 | 18511 | 944061 | | 52 | 19184 | 997568 | | 53 | 19869 | 1053057 | | 54 | 20566 | 1110564 | | 55 | 21275 | 1170125 | | 56 | 21996 | 1231776 | | 57 | 22729 | 1295553 | | 58 | 23474 | 1361492 | | 59 | 24231 | 1429629 | | 60 | 25000 | 1500000 | | 61 | 25781 | 1572641 | | 62 | 26574 | 1647588 | | 63 | 27379 | 1724877 | | 64 | 28196 | 1804544 | | 65 | 29025 | 1886625 | | 66 | 29866 | 1971156 | | 67 | 30719 | 2058173 | | 68 | 31584 | 2147712 | | 69 | 32461 | 2239809 | | 70 | 33350 | 2334500 | | 71 | 34251 | 2431821 | | 72 | 35164 | 2531808 | | 73 | 36089 | 2634497 | | 74 | 37026 | 2739924 | | 75 | 37975 | 2848125 | | 76 | 38936 | 2959136 | | 77 | 39909 | 3072993 | | 78 | 40894 | 3189732 | | 79 | 41891 | 3309389 | | 80 | 42900 | 3432000 | | 81 | 43921 | 3557601 | | 82 | 44954 | 3686228 | | 83 | 45999 | 3817917 | | 84 | 47056 | 3952704 | | 85 | 48125 | 4090625 | | 86 | 49206 | 4231716 | | 87 | 50299 | 4376013 | | 88 | 51404 | 4523552 | | 89 | 52521 | 4674369 | | 90 | 53650 | 4828500 | | 91 | 54791 | 4985981 | | 92 | 55944 | 5146848 | | 93 | 57109 | 5311137 | | 94 | 58286 | 5478884 | | 95 | 59475 | 5650125 | | 96 | 60676 | 5824896 | | 97 | 61889 | 6003233 | | 98 | 63114 | 6185172 | | 99 | 64351 | 6370749 | | 100 | 65600 | 6560000 |