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