addXP()
This function is used to add XP to a user.
xpData can be either a number or an object with { min, max }. Range values must be finite numbers with min <= max.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | The ID of the user. |
| guildId | string | ✅ | The guild ID. |
| xpData | number {min, max} | ✅ | The amount of XP to add. |
| username | string | ❌ | The name of user, if auto_create is on. |
Returns
- Promise<
XpResult>
Throws
XpFatal- if invalid parameters are provided.
[JS] Example
const { addXP } = require("simply-xp");
const userid = "326815959358898189";
const guildid = "867999056172052551";
const username = "Abadima";
const xp = 10000000; // or xp = {min: 5000000, max: 10000000}
addXP(userid, guildid, xp, username)
.then(console.log) // Returns the user object
.catch((err) => console.log(err)); // Returns the error