Socket
Socket
Sign inDemoInstall

hive-xp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hive-xp

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


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source
  1. Description.
  2. Setup.
  3. Example.
  4. Admin functions.
  5. Contact information.
  6. Donation.

Description


Easy to use level up / xp system package.

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

FunctionDescriptionUsage
createUsercreateUser Creates an entry in database for that user if it doesnt exist.Levels.createUser(<UserID - String>, <GuildID - String>);
deleteUserIf the entry exists, it deletes it from database.Levels.deleteUser(<UserID - String>, <GuildID - String>);
appendXpIt 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>);
appendLevelIt 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>);
setXpIt sets the xp to a specified amount and re-calculates the level.Levels.setXp(<UserID - String>, <GuildID - String>, <Amount - Integer>);
setLevelCalculates the xp required to reach a specified level and updates it.Levels.setLevel(<UserID - String>, <GuildID - String>, <Amount - Integer>);
subtractXpIt 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>);
subtractLevelIt 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

  • Discord: Nemijah#6392

  • Discord server: https://discord.gg/RTh79cwxxp

  • Email: hopetobylol@gmail.com

  • 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

    FAQs

    Package last updated on 20 Feb 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