A package for XP/Leveling on Discord.
npm install @elara-services/levelingclient: A v13/v14 discord.js client. (this will not work with any version below v13)
mongodb_uri: A mongodb connection uri. (this is for the package to save the data for servers/users/weekly)
messages, voice and xp
messages, level, voice and xp earned that week
arcane and cavancord
canvacord
stats: For any stats for the user (by default: messages, voice) but this could be added with any stats for the user (just use api.users.stats.inc)
background: Sets the background for the user's rank profiles.
colors: Sets the custom color for certain rank profiles.
toggles.locked: Freezes the user's data from earning XP
toggles.dms: Makes the bot not DM them level announcements
toggles.pings: Makes the bot not mention them in level announcements
js
const { Leveling } = require("@elara-services/leveling");
const lvls = new Leveling(client, "MONGODB_URI");
await lvls.start(); // This will tell the package to start listening for events.
`
Note: All data can be configured with
lvls.api.xxx
-------
$3
- See the rest on the api docs
#### Servers:
`js
const server = lvls.api.servers;
// Get the server data.
const serverData = await server.get("server_id");
if (serverData.status) {
console.log(serverData.data); // Returns the settings for the server.
}
// Toggle leveling on/off for a server. (by default: Leveling is off for the server)
const data = await server.toggle("server_id", "leveling");
console.log(data.message);
`
----
#### Users:
`js
const users = lvls.api.users;
// Get a user's data
const userData = await users.get("user_id", "server_id");
if (userData.status) {
console.log(userData.data); // Returns the user's data for that server.
}
`
-----
#### Rank Profile(s):
`js
const data = await lvls.getRankCard("user_id", "server_id");
// OR
const data = await lvls.getRankCard("user_id", "server_id", "rank_card_type");
// By default the "rank_card_type" is "arcane"
if (data.status) { // Get the rank profile image then send it to the channel
return channel.send({
files: [
{
name: "profile.png",
attachment: data.image,
}
]
});
}
`
----
#### Get Leaderboard Image
`js
const data = await lvls.getLeaderboard("server_id");
// OR
const data = await lvls.getLeaderboard(
"server_id",
{
page: 1, // The page for the leaderboard image
perPage: 5, // Up to 10 users returned in the leaderbaord image
sort: "top", // Sort by "top" or "bottom"
sortBy: "xp", // Sortby "xp" or "level"
},
"canvacord",
false, // If you want the weekly leaderboard, set this to: true
)
if (data.status) {
// Get the leaderboard image then send it to the channel.
return channel.send({
files: [
{
name: "lb.png",
attachment: data.image,
}
]
});
}
``