addXPVersion: v1.2
On this page
addXP()
This function is used to add experience to a user.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| message | Message | ✅ | The message object. |
| userId | string | ✅ | The User ID |
| guildId | string | ✅ | The Guild ID |
| xp | number {min, max} |
✅ | Amount of XP to add. With {min, max}, a random whole amount from min up to, not including, max. |
Returns
Section titled “Returns”- Promise<
{ level: number, xp: number }>
Throws
Section titled “Throws”new Error()- if the user ID, guild ID or amount is missing, or the amount is not a number.new Error()- if only one ofminandmaxis given.
[JS] Example
Section titled “[JS] Example”const { addXP } = require("simply-xp");
const userId = "770551872309166090";const guildId = "867999056172052551";const xp = 25; // or xp = { min: 15, max: 25 }
addXP(message, userId, guildId, xp) .then(console.log) // Returns the updated level and xp .catch((err) => console.log(err)); // Returns the error