addLevel
On this page
addLevel()
This function is used to add levels to a user.
When the user’s level actually changes, this function also triggers XpEvents callbacks (levelUp / levelDown) and awaits them before resolving.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | The ID of the user. |
| guildId | string | ✅ | The guild ID. |
| level | number | ✅ | The amount of levels to add. |
| username | string | ❌ | The name of user. |
Returns
Section titled “Returns”- Promise<
UserResult>
Throws
Section titled “Throws”XpFatal- if invalid parameters are provided.
[JS] Example
Section titled “[JS] Example”const { addLevel } = require("simply-xp");
const userid = "770551872309166090";const guildid = "867999056172052551";const level = 69;const username = "Rahuletto";
addLevel(userid, guildid, level, username) .then(console.log) // Returns the user object .catch((err) => console.log(err)); // Returns the error