Skip to content
Version: v1.4
On this page

fetch()

This function is used to fetch a user from the database. A user that has no record yet is created at 0 XP.

Parameter Type Required Description
userId string ✅ The ID of the user.
guildId string ✅ The guild ID of the user.
  • Promise<object>

Example:

{
level: 1,
xp: 150,
reqxp: 400, // XP needed for the next level
rank: 1,
shortxp: "150",
shortreq: "400"
}
  • new Error() - if the user ID or guild ID is missing.
const { fetch } = require("simply-xp");
const userId = "326815959358898189";
const guildId = "867999056172052551";
fetch(userId, guildId)
.then(console.log) // Returns the user's numbers
.catch((err) => console.log(err)); // Returns the error