1.0.9 • Published 3 years ago

hive-xp v1.0.9

Weekly downloads
122
License
ISC
Repository
-
Last release
3 years ago
  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

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

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

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago