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

hive-xp

v1.0.9

Published

1. [ Description. ](#desc) 2. [ Setup. ](#setup) 3. [ Example. ](#ex) 4. [ Admin functions. ](#af) 5. [ Contact information. ](#ci) 6. [ Donation. ](#donate)

Downloads

11

Readme

  1. Description.
  2. Setup.
  3. Example.
  4. Admin functions.
  5. Contact information.
  6. Donation.

Description

Setup

First, you need to require it obv.

const xp = require('hive-xp');

Then you need to set the url to your mongoose database:

xp.setURL("mongo url here");

Example

I'm assuming you have setted up the module as introduced in 'Setup' area.

Level up system example

if(message.author.bot) return; //prevents the bot from leveling up
const randomXp = Math.floor(Math.random() * 20);
const hasLeveledUp = await Levels.appendXp(message.author.id, message.guild.id, randomXp);
if (hasLeveledUp) {
   const user = await Levels.fetch(message.author.id, message.guild.id);
   message.channel.send(`Congrats ${message.author.tag}, you leveled up to ${user.level}!`);
}

Rank card example For the rank card command I'll be using canvacord

const member = message.mentions.members.last() || message.guild.members.cache.get(args[0]) || message.member;
const user = await Levels.fetch(member.id, message.guild.id);
const neededXp = Levels.xpFor(parseInt(user.level) + 1);

if(!user) return message.reply("You don't have any xp try sending some messages");

const rank = new canvacord.Rank()
    .setAvatar(member.user.displayAvatarURL({ dynamic: false, format: 'png' }))
    .setCurrentXP(user.xp)
    .setRequiredXP(neededXp)
    .setStatus(member.user.presence.status)
    .setLevel(user.level)
    .setRank(2, "idj", false)
    .setProgressBar("#FFA500", "COLOR")
    .setUsername(member.user.username)
    .setDiscriminator(member.user.discriminator);
    
    
    rank.build()
        .then(data => {
            const attachment = new MessageAttachment(data, "RankCard.png");
            message.channel.send(attachment);
        });

Admin functions

Function | Description | Usage :----- | :----: | -----: createUser | createUser Creates an entry in database for that user if it doesnt exist. | Levels.createUser(<UserID - String>, <GuildID - String>); deleteUser | If the entry exists, it deletes it from database. | Levels.deleteUser(<UserID - String>, <GuildID - String>); appendXp | It adds a specified amount of xp to the current amount of xp for that user, in that guild. It re-calculates the level. It creates a new user with that amount of xp, if there is no entry for that user. | Levels.appendXp(<UserID - String>, <GuildID - String>, <Amount - Integer>); appendLevel | It adds a specified amount of levels to current amount, re-calculates and sets the xp reqired to reach the new amount of levels. | Levels.appendLevel(<UserID - String>, <GuildID - String>, <Amount - Integer>); setXp | It sets the xp to a specified amount and re-calculates the level. | Levels.setXp(<UserID - String>, <GuildID - String>, <Amount - Integer>); setLevel | Calculates the xp required to reach a specified level and updates it. | Levels.setLevel(<UserID - String>, <GuildID - String>, <Amount - Integer>); subtractXp | It removes a specified amount of xp to the current amount of xp for that user, in that guild. It re-calculates the level. | Levels.subtractXp(<UserID - String>, <GuildID - String>, <Amount - Integer>); subtractLevel | It removes a specified amount of levels to current amount, re-calculates and sets the xp reqired to reach the new amount of levels. | Levels.subtractLevel(<UserID - String>, <GuildID - String>, <Amount - Number>);

Contact information

Donation

If you want to donate click here I'm saving up for my custom pc build, so if you wanna help me out you can.. Thanks for downloading