Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
1. [ Description. ](#desc) 2. [ Setup. ](#setup) 3. [ Example. ](#ex) 4. [ Admin functions. ](#af) 5. [ Contact information. ](#ci) 6. [ Donation. ](#donate)
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");
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);
});
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>); |
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
1. [ Description. ](#desc) 2. [ Setup. ](#setup) 3. [ Example. ](#ex) 4. [ Admin functions. ](#af) 5. [ Contact information. ](#ci) 6. [ Donation. ](#donate)
The npm package hive-xp receives a total of 0 weekly downloads. As such, hive-xp popularity was classified as not popular.
We found that hive-xp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.