Skip to content
Version: v1.4
On this page

addXP()

This function is used to add experience to a user.

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.
  • Promise<{ level: number, xp: number }>
  • new Error() - if the user ID or guild ID is missing, or the amount is not a finite number (Invalid XP amount).
  • new Error() - if only one of min and max is given.
  • Rejects if the database write fails.
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