simply-xp 1.3.6 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/FUNDING.yml +2 -2
  2. package/README.md +73 -43
  3. package/lib/src/add.d.ts +35 -0
  4. package/lib/src/add.js +23 -0
  5. package/lib/src/cards.d.ts +158 -0
  6. package/lib/src/cards.js +35 -0
  7. package/lib/src/charts.d.ts +27 -0
  8. package/lib/src/charts.js +10 -0
  9. package/lib/src/connect.d.ts +29 -0
  10. package/lib/src/connect.js +41 -0
  11. package/lib/src/create.d.ts +12 -0
  12. package/lib/src/create.js +11 -0
  13. package/lib/src/fetch.d.ts +12 -0
  14. package/lib/src/fetch.js +11 -0
  15. package/lib/src/functions/database.d.ts +164 -0
  16. package/lib/src/functions/database.js +78 -0
  17. package/lib/src/functions/https.d.ts +26 -0
  18. package/lib/src/functions/https.js +15 -0
  19. package/lib/src/functions/utilities.d.ts +79 -0
  20. package/lib/src/functions/utilities.js +43 -0
  21. package/lib/src/functions/xplogs.d.ts +81 -0
  22. package/lib/src/functions/xplogs.js +15 -0
  23. package/lib/src/leaderboard.d.ts +11 -0
  24. package/lib/src/leaderboard.js +10 -0
  25. package/lib/src/migrate.d.ts +27 -0
  26. package/lib/src/migrate.js +19 -0
  27. package/lib/src/remove.d.ts +29 -0
  28. package/lib/src/remove.js +23 -0
  29. package/lib/src/reset.d.ts +12 -0
  30. package/lib/src/reset.js +12 -0
  31. package/lib/src/roleSetup.d.ts +78 -0
  32. package/lib/src/roleSetup.js +47 -0
  33. package/lib/src/set.d.ts +26 -0
  34. package/lib/src/set.js +23 -0
  35. package/lib/xp.d.ts +62 -0
  36. package/lib/xp.js +56 -0
  37. package/package.json +50 -36
  38. package/index.d.ts +0 -108
  39. package/simplyxp.js +0 -33
  40. package/src/Fonts/Baloo-Regular.ttf +0 -0
  41. package/src/addLevel.js +0 -66
  42. package/src/addXP.js +0 -104
  43. package/src/charts.js +0 -92
  44. package/src/connect.js +0 -21
  45. package/src/create.js +0 -28
  46. package/src/fetch.js +0 -74
  47. package/src/leaderboard.js +0 -51
  48. package/src/lvlRole.js +0 -53
  49. package/src/models/level.js +0 -10
  50. package/src/models/lvlrole.js +0 -8
  51. package/src/rank.js +0 -295
  52. package/src/reset.js +0 -22
  53. package/src/roleSetup.js +0 -121
  54. package/src/setLevel.js +0 -42
  55. package/src/setXP.js +0 -23
@@ -0,0 +1,164 @@
1
+ import { Collection } from "mongodb";
2
+ /**
3
+ * Options for creating a user document.
4
+ * @property {string} collection - The collection to create the document in.
5
+ * @property {object} data - The data to create the document with.
6
+ * @property {string} data.guild - The guild ID.
7
+ * @property {string} [data.user] - The user ID.
8
+ * @property {string} [data.name] - The username.
9
+ * @property {number} [data.level] - The level.
10
+ * @property {number} [data.xp] - The XP.
11
+ * @property {number} [data.xp_rate] - The XP rate.
12
+ */
13
+ export interface UserOptions {
14
+ collection: "simply-xps";
15
+ data: {
16
+ guild: string;
17
+ user?: string;
18
+ name?: string;
19
+ level?: number;
20
+ xp?: number;
21
+ xp_rate?: number;
22
+ };
23
+ }
24
+ /**
25
+ * The result of a user document.
26
+ * @property {string} [_id] - The ID of the document.
27
+ * @property {string} user - The user ID.
28
+ * @property {string} [name] - The username.
29
+ * @property {string} guild - The guild ID.
30
+ * @property {string} lastUpdated - ISO String of the last time the user was updated.
31
+ * @property {number} level - The level.
32
+ * @property {number} xp - The XP.
33
+ * @property {number} [xp_rate] - The XP rate.
34
+ */
35
+ export interface UserResult {
36
+ _id?: string;
37
+ user: string;
38
+ name?: string;
39
+ guild: string;
40
+ lastUpdated: string;
41
+ level: number;
42
+ xp: number;
43
+ xp_rate?: number;
44
+ }
45
+ /**
46
+ * Options for creating a level role document.
47
+ * @property {string} collection - The collection to create the document in.
48
+ * @property {object} data - The data to create the document with.
49
+ * @property {string} data.guild - The guild ID.
50
+ * @property {object} data.lvlrole - The level role data.
51
+ * @property {number} data.lvlrole.lvl - The level.
52
+ * @property {string | Array<string>} [data.lvlrole.role] - The role ID(s).
53
+ */
54
+ export interface LevelRoleOptions {
55
+ collection: "simply-xp-levelroles";
56
+ data: {
57
+ guild: string;
58
+ lvlrole: {
59
+ lvl: number | null;
60
+ role?: string | Array<string> | null;
61
+ };
62
+ };
63
+ }
64
+ /**
65
+ * The result of a level role document.
66
+ * @property {string} [_id] - The ID of the document.
67
+ * @property {string} guild - The guild ID.
68
+ * @property {object} lvlrole - The level role data.
69
+ * @property {number} lvlrole.lvl - The level.
70
+ * @property {string | Array<string>} [lvlrole.role] - The role ID(s).
71
+ * @property {string} lastUpdated - ISO String of the last time the level role was updated.
72
+ */
73
+ export type LevelRoleResult = {
74
+ _id?: string;
75
+ guild: string;
76
+ lvlrole: {
77
+ lvl: number;
78
+ role?: string | Array<string>;
79
+ };
80
+ lastUpdated: string;
81
+ };
82
+ /**
83
+ * Database class providing methods to interact with the database.
84
+ * @class db
85
+ */
86
+ export declare class db {
87
+ /**
88
+ * Gets a collection from the database.
89
+ * @param {collection} collection - The collection to get.
90
+ * @link https://simplyxp.js.org/docs/next/handlers/database#getCollection Documentation
91
+ * @returns {Collection} The collection.
92
+ * @throws {XpFatal} Throws an error if there is no database connection, or database type is invalid.
93
+ */
94
+ static getCollection(collection: string): Collection;
95
+ /**
96
+ * Creates one document in the database.
97
+ *
98
+ * @async
99
+ * @param {UserOptions | LevelRoleOptions} query - The document to create.
100
+ * @link https://simplyxp.js.org/docs/next/handlers/database#createOne Documentation
101
+ * @returns {Promise<UserResult | LevelRoleResult>} The created document.
102
+ * @throws {XpFatal} Throws an error if there is no database connection.
103
+ */
104
+ static createOne(query: UserOptions | LevelRoleOptions): Promise<UserResult | LevelRoleResult>;
105
+ /**
106
+ * Deletes multiple documents from the database.
107
+ * @async
108
+ * @param {UserOptions | LevelRoleOptions} query - The documents to delete.
109
+ * @link https://simplyxp.js.org/docs/next/handlers/database#deleteMany Documentation
110
+ * @returns {Promise<boolean>} `true` if the documents were successfully deleted, otherwise `false`.
111
+ * @throws {XpFatal} Throws an error if there is no database connection.
112
+ */
113
+ static deleteMany(query: UserOptions | LevelRoleOptions): Promise<boolean>;
114
+ /**
115
+ * Deletes one document from the database.
116
+ *
117
+ * @async
118
+ * @param {UserOptions | LevelRoleOptions} query - The document to delete.
119
+ * @link https://simplyxp.js.org/docs/next/handlers/database#deleteOne Documentation
120
+ * @returns {Promise<boolean>} `true` if the document was successfully deleted, otherwise `false`.
121
+ * @throws {XpFatal} Throws an error if there is no database connection.
122
+ */
123
+ static deleteOne(query: UserOptions | LevelRoleOptions): Promise<boolean>;
124
+ /**
125
+ * Finds one document in the database.
126
+ *
127
+ * @async
128
+ * @param {UserOptions | LevelRoleOptions} query - The query to search for the document.
129
+ * @link https://simplyxp.js.org/docs/next/handlers/database#findOne Documentation
130
+ * @returns {Promise<UserResult | LevelRoleResult>} The found document.
131
+ * @throws {XpFatal} Throws an error if there is no database connection.
132
+ */
133
+ static findOne(query: UserOptions | LevelRoleOptions): Promise<UserResult | LevelRoleResult>;
134
+ /**
135
+ * Finds multiple documents in the database.
136
+ *
137
+ * @async
138
+ * @param {UserOptions | LevelRoleOptions} query - The query to search for multiple documents.
139
+ * @link https://simplyxp.js.org/docs/next/handlers/database#find Documentation
140
+ * @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
141
+ * @throws {XpFatal} Throws an error if there is no database connection.
142
+ */
143
+ static find(query: UserOptions | LevelRoleOptions): Promise<UserResult[] | LevelRoleResult[]>;
144
+ /**
145
+ * Finds all documents in a collection.
146
+ * @param {"simply-xps" | "simply-xp-levelroles"} collection - The collection to search for all documents.
147
+ * @link https://simplyxp.js.org/docs/next/handlers/database#findAll Documentation
148
+ * @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
149
+ * @throws {XpFatal} Throws an error if there is no database connection.
150
+ */
151
+ static findAll(collection: "simply-xps" | "simply-xp-levelroles"): Promise<UserResult[] | LevelRoleResult[]>;
152
+ /**
153
+ * Updates one document in the database.
154
+ *
155
+ * @async
156
+ * @param {UserOptions | LevelRoleOptions} filter - The document to update.
157
+ * @param {UserOptions | LevelRoleOptions} update - The document update data.
158
+ * @param {object} [options] - MongoDB options for updating the document.
159
+ * @link https://simplyxp.js.org/docs/next/handlers/database#updateOne Documentation
160
+ * @returns {Promise<UserResult | LevelRoleResult>} The updated document.
161
+ * @throws {XpFatal} Throws an error if there is no database connection.
162
+ */
163
+ static updateOne(filter: UserOptions | LevelRoleOptions, update: UserOptions | LevelRoleOptions, options?: object): Promise<UserResult | LevelRoleResult>;
164
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Handle database errors
4
+ * @param {Error} error
5
+ * @param {string} functionName
6
+ * @returns {void}
7
+ * @private
8
+ */function handleError(error,functionName){throw new xplogs_1.XpFatal({function:"db."+functionName,message:error})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.db=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp");class db{
9
+ /**
10
+ * Gets a collection from the database.
11
+ * @param {collection} collection - The collection to get.
12
+ * @link https://simplyxp.js.org/docs/next/handlers/database#getCollection Documentation
13
+ * @returns {Collection} The collection.
14
+ * @throws {XpFatal} Throws an error if there is no database connection, or database type is invalid.
15
+ */
16
+ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"getCollection()",message:"No database connection"});if("mongodb"!==xp_1.xp.dbType)throw new xplogs_1.XpFatal({function:"getCollection()",message:"MongoDB has to be your database type to use this function."});return xp_1.xp.database.db().collection(collection)}
17
+ /**
18
+ * Creates one document in the database.
19
+ *
20
+ * @async
21
+ * @param {UserOptions | LevelRoleOptions} query - The document to create.
22
+ * @link https://simplyxp.js.org/docs/next/handlers/database#createOne Documentation
23
+ * @returns {Promise<UserResult | LevelRoleResult>} The created document.
24
+ * @throws {XpFatal} Throws an error if there is no database connection.
25
+ */static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});switch(xp_1.xp.dbType){case"mongodb":xp_1.xp.database.db().collection(query.collection).insertOne({...query.data,lastUpdated:(new Date).toISOString()}).catch(error=>handleError(error,"createOne()"));break;case"sqlite":"simply-xps"===query.collection?xp_1.xp.database.prepare('INSERT INTO "simply-xps" (user, guild, level, name, lastUpdated, xp, xp_rate) VALUES (?, ?, ?, ?, ?, ?, ?)').run(query.data.user,query.data.guild,query.data.level,query.data?.name,(new Date).toISOString(),query.data.xp,query.data.xp_rate):xp_1.xp.database.prepare('INSERT INTO "simply-xp-levelroles" (gid, lvlrole, lastUpdated) VALUES (?, ?, ?)').run(query.data.guild,JSON.stringify(query.data.lvlrole),(new Date).toISOString())}return db.findOne(query)}
26
+ /**
27
+ * Deletes multiple documents from the database.
28
+ * @async
29
+ * @param {UserOptions | LevelRoleOptions} query - The documents to delete.
30
+ * @link https://simplyxp.js.org/docs/next/handlers/database#deleteMany Documentation
31
+ * @returns {Promise<boolean>} `true` if the documents were successfully deleted, otherwise `false`.
32
+ * @throws {XpFatal} Throws an error if there is no database connection.
33
+ */static async deleteMany(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteMany()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteMany(query.data).catch(error=>handleError(error,"deleteMany()"));break;case"sqlite":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE gid = ?')).run(query.data.guild)}return!!e}
34
+ /**
35
+ * Deletes one document from the database.
36
+ *
37
+ * @async
38
+ * @param {UserOptions | LevelRoleOptions} query - The document to delete.
39
+ * @link https://simplyxp.js.org/docs/next/handlers/database#deleteOne Documentation
40
+ * @returns {Promise<boolean>} `true` if the document was successfully deleted, otherwise `false`.
41
+ * @throws {XpFatal} Throws an error if there is no database connection.
42
+ */static async deleteOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"deleteOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).deleteOne(query.data).catch(error=>handleError(error,"deleteOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('DELETE FROM "simply-xps" WHERE guild = ? AND user = ?').run(query.data.guild,query.data.user):(e=(e=await this.find(query)).filter(row=>row.lvlrole.lvl===query.data.lvlrole.lvl)[0],xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE gid = ? AND lvlrole = ?').run(query.data.guild,JSON.stringify(e.lvlrole)))}return!!e}
43
+ /**
44
+ * Finds one document in the database.
45
+ *
46
+ * @async
47
+ * @param {UserOptions | LevelRoleOptions} query - The query to search for the document.
48
+ * @link https://simplyxp.js.org/docs/next/handlers/database#findOne Documentation
49
+ * @returns {Promise<UserResult | LevelRoleResult>} The found document.
50
+ * @throws {XpFatal} Throws an error if there is no database connection.
51
+ */static async findOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"findOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e="simply-xps"===query.collection?await xp_1.xp.database.db().collection(query.collection).findOne(query.data).catch(error=>handleError(error,"findOne()")):await xp_1.xp.database.db().collection(query.collection).findOne({guild:query.data.guild,"lvlrole.lvl":query.data.lvlrole.lvl}).catch(error=>handleError(error,"findOne()"));break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ? AND user = ?').get(query.data.guild,query.data.user):(e=await this.find(query)).filter(row=>row.lvlrole.lvl===query.data.lvlrole.lvl)[0]}return e}
52
+ /**
53
+ * Finds multiple documents in the database.
54
+ *
55
+ * @async
56
+ * @param {UserOptions | LevelRoleOptions} query - The query to search for multiple documents.
57
+ * @link https://simplyxp.js.org/docs/next/handlers/database#find Documentation
58
+ * @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
59
+ * @throws {XpFatal} Throws an error if there is no database connection.
60
+ */static async find(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"find()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(query.collection).find(query.data).toArray().catch(error=>handleError(error,"find()"));break;case"sqlite":"simply-xps"===query.collection?e=xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ?').all(query.data.guild):(e=xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles" WHERE gid = ?').all(query.data.guild)).length&&(e=await Promise.all(e.map(async row=>(row.lvlrole=JSON.parse(row.lvlrole),row))))}return e}
61
+ /**
62
+ * Finds all documents in a collection.
63
+ * @param {"simply-xps" | "simply-xp-levelroles"} collection - The collection to search for all documents.
64
+ * @link https://simplyxp.js.org/docs/next/handlers/database#findAll Documentation
65
+ * @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
66
+ * @throws {XpFatal} Throws an error if there is no database connection.
67
+ */static async findAll(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"findAll()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":e=xp_1.xp.database.db().collection(collection).find().toArray().catch(error=>handleError(error,"findAll()"));break;case"sqlite":"simply-xps"===collection?e=xp_1.xp.database.prepare('SELECT * FROM "simply-xps"').all():(e=xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles"').all()).length&&(e=await Promise.all(e.map(async row=>(row.lvlrole=JSON.parse(row.lvlrole),row))))}return e}
68
+ /**
69
+ * Updates one document in the database.
70
+ *
71
+ * @async
72
+ * @param {UserOptions | LevelRoleOptions} filter - The document to update.
73
+ * @param {UserOptions | LevelRoleOptions} update - The document update data.
74
+ * @param {object} [options] - MongoDB options for updating the document.
75
+ * @link https://simplyxp.js.org/docs/next/handlers/database#updateOne Documentation
76
+ * @returns {Promise<UserResult | LevelRoleResult>} The updated document.
77
+ * @throws {XpFatal} Throws an error if there is no database connection.
78
+ */static async updateOne(filter,update,options){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"updateOne()",message:"No database connection"});switch(xp_1.xp.dbType){case"mongodb":await xp_1.xp.database.db().collection(update.collection).updateOne(filter.data,{$set:{...update.data,lastUpdated:(new Date).toISOString()}},options).catch(error=>handleError(error,"updateOne()"));break;case"sqlite":if("simply-xps"===filter.collection&&"simply-xps"===update.collection)xp_1.xp.database.prepare(`UPDATE "simply-xps" SET xp_rate = ?, xp = ?, lastUpdated = ?, level = ? ${update.data?.name?", name = ?":""} WHERE guild = ? AND user = ?`).run(update.data?.name?[update.data.xp_rate,update.data.xp,(new Date).toISOString(),update.data.level,update.data.name,filter.data.guild,filter.data.user]:[update.data.xp_rate,update.data.xp,(new Date).toISOString(),update.data.level,filter.data.guild,filter.data.user]);else{if("simply-xp-levelroles"!==filter.collection||"simply-xp-levelroles"!==update.collection)throw new xplogs_1.XpFatal({function:"updateOne()",message:"Collection mismatch, expected same collection on both filter and update."});xp_1.xp.database.prepare('UPDATE "simply-xp-levelroles" SET lvlrole = ? WHERE gid = ?').run(JSON.stringify(update.data.lvlrole),filter.data.guild)}}return db.findOne(update)}}exports.db=db;
@@ -0,0 +1,26 @@
1
+ /// <reference types="node" />
2
+ interface HttpsOptions {
3
+ body?: object;
4
+ endpoint?: string;
5
+ headers?: Record<string, string>;
6
+ method?: "GET" | "POST";
7
+ responseType?: "json" | "stream" | "text";
8
+ statusCode?: number;
9
+ timeout?: number;
10
+ }
11
+ /**
12
+ * Send HTTPS Request.
13
+ * @param {string} url
14
+ * @param {HttpsOptions} options
15
+ * @param {Object} [options.body]
16
+ * @param {string} [options.endpoint]
17
+ * @param {Record<string, string>} [options.headers]
18
+ * @param {("GET"|"POST")} [options.method="GET"]
19
+ * @param {("json"|"stream"|"text")} [options.responseType="json"] - Expected response type.
20
+ * @param {number} [options.statusCode] - Expected status code.
21
+ * @param {number} [options.timeout] - Request Timeout in Milliseconds
22
+ * @returns {Promise<Object|Buffer|string>} - Returns the response from the request.
23
+ * @throws {PromiseRejectedResult} - If the request fails.
24
+ */
25
+ export declare function https(url: string, options?: HttpsOptions): Promise<object | Buffer | string>;
26
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Send HTTPS Request.
4
+ * @param {string} url
5
+ * @param {HttpsOptions} options
6
+ * @param {Object} [options.body]
7
+ * @param {string} [options.endpoint]
8
+ * @param {Record<string, string>} [options.headers]
9
+ * @param {("GET"|"POST")} [options.method="GET"]
10
+ * @param {("json"|"stream"|"text")} [options.responseType="json"] - Expected response type.
11
+ * @param {number} [options.statusCode] - Expected status code.
12
+ * @param {number} [options.timeout] - Request Timeout in Milliseconds
13
+ * @returns {Promise<Object|Buffer|string>} - Returns the response from the request.
14
+ * @throws {PromiseRejectedResult} - If the request fails.
15
+ */function https(url,options={}){return new Promise((resolve,reject)=>{const e=(0,https_1.request)({agent:new https_1.Agent({keepAlive:!0}),headers:options?.headers||{"Content-Type":"application/json"},hostname:new url_1.URL(url).hostname,method:options?.method||"GET",path:options?.endpoint||new url_1.URL(url).pathname},response=>{const e=[];response.on("error",reject),response.on("data",chunk=>e.push(Buffer.from(chunk))),response.on("end",()=>{options?.statusCode&&response.statusCode!==options?.statusCode&&reject({error:"Unexpected Status Code",status:response.statusCode});try{switch(options?.responseType||"json"){case"json":resolve(JSON.parse(Buffer.concat(e).toString()));break;case"stream":resolve(Buffer.concat(e));break;default:resolve(Buffer.concat(e).toString())}}catch(e){reject(e)}})}).on("error",reject);e.setTimeout(options?.timeout||5e3,()=>{e.destroy(),reject({error:"Request Timed Out",status:408})}),options?.body&&e.write(JSON.stringify(options.body)),e.end()})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.https=void 0;const https_1=require("https"),url_1=require("url");exports.https=https;
@@ -0,0 +1,79 @@
1
+ import { Database } from "better-sqlite3";
2
+ import { Plugin } from "../../xp";
3
+ import { MongoClient } from "mongodb";
4
+ /**
5
+ * Options for clean function.
6
+ * @property {boolean} [db=false] - Whether to clean the database or not.
7
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/clean
8
+ */
9
+ type CleanOptions = {
10
+ db?: boolean;
11
+ };
12
+ /**
13
+ * Options for the XP client.
14
+ * @property {boolean} auto_create - Whether to automatically create a user if they don't exist in the database.
15
+ * @property {boolean} auto_clean - Whether to automatically clean database and cache.
16
+ * @property {object} dbOptions - The database options.
17
+ * @property {"mongodb" | "sqlite"} dbOptions.type - The database type.
18
+ * @property {MongoClient | Database} dbOptions.database - The database connection.
19
+ * @property {boolean} debug - Whether to enable debug logs.
20
+ * @property {boolean} notify - Enable/Disable console notifications.
21
+ * @property {"slow" | "normal" | "fast" | number} xp_rate - The XP rate.
22
+ */
23
+ interface NewClientOptions {
24
+ auto_create: boolean;
25
+ auto_clean: boolean;
26
+ dbOptions: {
27
+ type: "mongodb" | "sqlite";
28
+ database: MongoClient | Database;
29
+ };
30
+ debug: boolean;
31
+ notify: boolean;
32
+ xp_rate?: "slow" | "normal" | "fast" | number;
33
+ }
34
+ /**
35
+ * Helps to clean the database and cache, more in the future, maybe.
36
+ * @param {CleanOptions} [options={}] - The options.
37
+ * @param {boolean?} options.db - Whether to clean the database or not.
38
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/clean
39
+ * @returns {void} - Nothing.
40
+ * @throws {XpFatal} If an error occurs.
41
+ */
42
+ export declare function clean(options?: CleanOptions): void;
43
+ /**
44
+ * Convert XP to level and vice versa.
45
+ *
46
+ * @param {number} value.
47
+ * @param {"xp" | "level"} type - Type to convert from (Default: level).
48
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/convert
49
+ * @returns {number} - The converted value. (XP to level or level to XP)
50
+ * @throws {XpFatal} If an invalid type is provided or if the value is not provided.
51
+ */
52
+ export declare function convertFrom(value: number, type?: ("xp" | "level")): number;
53
+ /**
54
+ * Registers fonts from URLs or paths (For convenience).
55
+ * @param {string} pathOrURL - The path or URL to the font.
56
+ * @param {string} name - The name of the font.
57
+ * @param {number} [timeout=1500] - The timeout for the request.
58
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/registerFont
59
+ * @returns {Promise<void>} - Nothing.
60
+ * @throws {XpFatal} If an invalid path or URL is provided.
61
+ */
62
+ export declare function registerFont(pathOrURL: string, name: string, timeout?: number): Promise<void>;
63
+ /**
64
+ * Register Simply-XP Plugins.
65
+ * @param {Plugin[]} plugins - The plugins to register.
66
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/registerPlugins
67
+ * @returns {void} - Nothing.
68
+ * @throws {XpFatal} If an invalid plugin is provided.
69
+ */
70
+ export declare function registerPlugins(plugins: Plugin[]): void;
71
+ /**
72
+ * Updates the options of the XP client.
73
+ * @param {NewClientOptions} clientOptions - The new options to update.
74
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/updateOptions
75
+ * @returns {void} - Nothing.
76
+ * @throws {XpFatal} If an invalid option is provided.
77
+ */
78
+ export declare function updateOptions(clientOptions: NewClientOptions): void;
79
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Helps to clean the database and cache, more in the future, maybe.
4
+ * @param {CleanOptions} [options={}] - The options.
5
+ * @param {boolean?} options.db - Whether to clean the database or not.
6
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/clean
7
+ * @returns {void} - Nothing.
8
+ * @throws {XpFatal} If an error occurs.
9
+ */function clean(options={}){options?.db&&xp_1.xp?.database&&xp_1.db.findAll("simply-xps").then(users=>{users.forEach(async user=>{0===user.level&&0===user.xp&&await xp_1.db.deleteOne({collection:"simply-xps",data:{user:user.user,guild:user.guild}})}),xplogs_1.XpLog.debug("clean()","REMOVED ALL USERS WITHOUT XP")}),(0,canvas_1.clearAllCache)(),xplogs_1.XpLog.debug("clean()","CLEARED CANVAS CACHE")}
10
+ /**
11
+ * Convert XP to level and vice versa.
12
+ *
13
+ * @param {number} value.
14
+ * @param {"xp" | "level"} type - Type to convert from (Default: level).
15
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/convert
16
+ * @returns {number} - The converted value. (XP to level or level to XP)
17
+ * @throws {XpFatal} If an invalid type is provided or if the value is not provided.
18
+ */function convertFrom(value,type="level"){if(isNaN(value))throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Value was not provided"});if("xp"!==type&&"level"!==type)throw new xplogs_1.XpFatal({function:"convert()",message:"Invalid type provided"});if("level"===type)return Math.pow(Math.max(0,value)/xp_1.xp.xp_rate,2);if("xp"===type)return Math.floor(xp_1.xp.xp_rate*Math.sqrt(Math.max(0,value)));throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Invalid type provided"})}
19
+ /**
20
+ * Registers fonts from URLs or paths (For convenience).
21
+ * @param {string} pathOrURL - The path or URL to the font.
22
+ * @param {string} name - The name of the font.
23
+ * @param {number} [timeout=1500] - The timeout for the request.
24
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/registerFont
25
+ * @returns {Promise<void>} - Nothing.
26
+ * @throws {XpFatal} If an invalid path or URL is provided.
27
+ */async function registerFont(pathOrURL,name,timeout=1500){xp_1.xp.registeredFonts.includes(name)||(pathOrURL.startsWith("https://")?await(0,xp_1.https)(pathOrURL,{responseType:"stream",timeout:timeout}).then(font=>{canvas_1.GlobalFonts.register(font,name),xp_1.xp.registeredFonts.push(name)}).catch(error=>{throw new xplogs_1.XpFatal({function:"registerFont()",message:`Failed to register font from URL
28
+ `+JSON.stringify(error)})}):(canvas_1.GlobalFonts.registerFromPath(pathOrURL,name),xp_1.xp.registeredFonts.push(name)))}
29
+ /**
30
+ * Register Simply-XP Plugins.
31
+ * @param {Plugin[]} plugins - The plugins to register.
32
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/registerPlugins
33
+ * @returns {void} - Nothing.
34
+ * @throws {XpFatal} If an invalid plugin is provided.
35
+ */function registerPlugins(plugins){if(!Array.isArray(plugins))throw new xplogs_1.XpFatal({function:"registerPlugins()",message:"Plugins must be an array"});plugins.forEach(async plugin=>{let e=!1,t=!0;if(plugin?.initialize&&plugin?.name||(t=!1,xplogs_1.XpLog.warn("registerPlugins()",plugin?.name?plugin.name.toUpperCase()+" PLUGIN NOT INITIALIZED: No initialize function provided.":"INVALID PLUGIN PROVIDED")),Array.isArray(plugin?.requiredVersions)&&!plugin.requiredVersions.includes(xp_1.xp.version)&&(plugin.requiredVersions.forEach(version=>{parseInt(version)?t=!(!parseInt(version)||1!==version.length||xp_1.xp.version.split(".")[0]!==version):version.match(/\d\.\d\.\d/)||t||(e=!0,t=!0)}),e&&xplogs_1.XpLog.warn("registerPlugins()",plugin.name.toUpperCase()+" PLUGIN FAILED VERSION CHECKS, ANYWAYS..."),t||e||xplogs_1.XpLog.warn("registerPlugins()",plugin.name.toUpperCase()+" PLUGIN NOT INITIALIZED: Requires: v"+plugin.requiredVersions.join(", v"))),t)try{await plugin.initialize(xp_1.xp).then(()=>{xplogs_1.XpLog.info("registerPlugins()",plugin.name.toUpperCase()+" PLUGIN INITIALIZED")})}catch(e){throw new xplogs_1.XpFatal({function:"registerPlugins()",message:`Failed to initialize plugin: ${plugin.name}
36
+ `+e})}})}
37
+ /**
38
+ * Updates the options of the XP client.
39
+ * @param {NewClientOptions} clientOptions - The new options to update.
40
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/Functions/updateOptions
41
+ * @returns {void} - Nothing.
42
+ * @throws {XpFatal} If an invalid option is provided.
43
+ */function updateOptions(clientOptions){if(!clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options were not provided"});if("object"!=typeof clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options must be an object"});if(clientOptions?.auto_clean&&(xp_1.xp.auto_clean=!0),clientOptions?.auto_create&&(xp_1.xp.auto_create=!0),clientOptions?.debug&&(xp_1.xp.debug=!0),clientOptions?.notify&&(xp_1.xp.notify=clientOptions.notify),clientOptions?.xp_rate&&("number"==typeof clientOptions.xp_rate||["fast","normal","slow"].includes(clientOptions.xp_rate))&&(xp_1.xp.xp_rate="slow"===clientOptions.xp_rate?.05:"normal"===clientOptions.xp_rate?.1:"fast"===clientOptions.xp_rate?.5:clientOptions.xp_rate),clientOptions.dbOptions&&"object"==typeof clientOptions.dbOptions&&clientOptions.dbOptions.type&&clientOptions.dbOptions.database){var{type:e,database:t}=clientOptions.dbOptions;if(!(e&&"mongodb"===e||"sqlite"===e))throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid database type provided"});if(xp_1.xp.dbType=e,t){xp_1.xp.database=t;const n="mongodb"===xp_1.xp.dbType?{name:"MongoDB",type:"mongodb",min:3,max:6}:{name:"Better-SQLite3",type:"better-sqlite3",min:7,max:9};(0,connect_1.checkPackageVersion)(n.type,n.min,n.max).then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:`${n.name} V${n.min} up to V${n.max} is required.`});switch(xp_1.xp.dbType){case"mongodb":xp_1.xp.database.db().command({ping:1}).catch(()=>{throw xp_1.xp.database=void 0,new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid MongoDB connection"})});break;case"sqlite":try{xp_1.xp.database.prepare("SELECT 1").get()}catch(e){throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid SQLite connection"})}}})}}clientOptions?.auto_clean&&clean({db:!0}),xp_1.db.findAll("simply-xps").then(users=>{users.filter(user=>user?.xp_rate!==xp_1.xp.xp_rate).map(async user=>{await xp_1.db.updateOne({collection:"simply-xps",data:{user:user.user,guild:user.guild}},{collection:"simply-xps",data:{user:user.user,guild:user.guild,level:convertFrom(user.xp,"xp"),xp:user.xp,xp_rate:xp_1.xp.xp_rate}})}),xplogs_1.XpLog.debug("updateOptions()","UPDATED ALL USERS WITH NEW XP RATE")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateOptions=exports.registerPlugins=exports.registerFont=exports.convertFrom=exports.clean=void 0;const connect_1=require("../connect"),canvas_1=require("@napi-rs/canvas"),xp_1=require("../../xp"),xplogs_1=require("./xplogs");exports.clean=clean,exports.convertFrom=convertFrom,exports.registerFont=registerFont,exports.registerPlugins=registerPlugins,exports.updateOptions=updateOptions;
@@ -0,0 +1,81 @@
1
+ import { UserResult } from "./database";
2
+ type errOptions = {
3
+ function: string;
4
+ message: string | Error;
5
+ };
6
+ /**
7
+ * Emits a fatal error message
8
+ * @class XpFatal
9
+ */
10
+ export declare class XpFatal extends Error {
11
+ /**
12
+ * Emits a simple error message
13
+ * @param {errOptions} options
14
+ * @private
15
+ */
16
+ constructor(options: errOptions);
17
+ }
18
+ /**
19
+ * Emits a log message
20
+ * @class XpLog
21
+ * @private
22
+ */
23
+ export declare class XpLog {
24
+ /**
25
+ * Emits a log message with the specified level
26
+ * @param {("debug" | "error" | "info" | "warn")} level - The log level (e.g., 'info', 'error', 'warn')
27
+ * @param {string} xpFunction - The command or context of the log message
28
+ * @param {string} message - The log message
29
+ * @private
30
+ */
31
+ static log(level: ("debug" | "error" | "info" | "warn"), xpFunction: string, message: string): void;
32
+ /**
33
+ * Emits a debug log
34
+ * @param {string} xpFunction - The command or context of the log message
35
+ * @param {string} message - The log message
36
+ * @private
37
+ */
38
+ static debug(xpFunction: string, message: string): void;
39
+ /**
40
+ * Emits an info log
41
+ * @param {string} xpFunction - The command or context of the log message
42
+ * @param {string} message - The log message
43
+ * @returns {boolean} Returns true
44
+ * @private
45
+ */
46
+ static info(xpFunction: string, message: string): boolean;
47
+ /**
48
+ * Emits an error log
49
+ * @param {string} xpFunction - The command or context of the log message
50
+ * @param {string} message - The log message
51
+ * @returns {boolean} Returns false
52
+ * @private
53
+ */
54
+ static err(xpFunction: string, message: string): boolean;
55
+ /**
56
+ * Emits a warning log
57
+ * @param {string} xpFunction - The command or context of the log message
58
+ * @param {string} message - The log message
59
+ * @private
60
+ */
61
+ static warn(xpFunction: string, message: string): void;
62
+ }
63
+ export type XpEventCallback = {
64
+ custom: (message: string) => void;
65
+ debug: (xpFunction: string, message: string) => void;
66
+ error: (xpFunction: string, message: string) => void;
67
+ info: (xpFunction: string, message: string) => void;
68
+ levelDown: (data: UserResult, lostRoles: string[]) => void;
69
+ levelUp: (data: UserResult, newRoles: string[]) => void;
70
+ warn: (xpFunction: string, message: string) => void;
71
+ };
72
+ /**
73
+ * Event handler for XP events
74
+ * @class XpEvents
75
+ * @public
76
+ */
77
+ export declare class XpEvents {
78
+ static eventCallback: XpEventCallback;
79
+ static on(callbacks: XpEventCallback): void;
80
+ }
81
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.XpEvents=exports.XpLog=exports.XpFatal=void 0;const xp_1=require("../../xp");class XpFatal extends Error{constructor(options){super(options.function+": "+options.message)}}exports.XpFatal=XpFatal,Object.defineProperty(XpFatal.prototype,"name",{value:"SimplyXpFatal"});class XpLog{static log(level,xpFunction,message){var e=XpEvents.eventCallback?.[level],t=level.toUpperCase(),s=xpFunction.toUpperCase();e&&"function"==typeof e?e(xpFunction,message):console.log(`[SIMPLY XP] ${{debug:"",info:"",error:"",warn:""}[level]}(${t}) ${s}: `+message)}static debug(xpFunction,message){xp_1.xp.debug&&XpLog.log("debug",xpFunction,message)}
2
+ /**
3
+ * Emits an info log
4
+ * @param {string} xpFunction - The command or context of the log message
5
+ * @param {string} message - The log message
6
+ * @returns {boolean} Returns true
7
+ * @private
8
+ */static info(xpFunction,message){return xp_1.xp.notify&&XpLog.log("info",xpFunction,message),!0}
9
+ /**
10
+ * Emits an error log
11
+ * @param {string} xpFunction - The command or context of the log message
12
+ * @param {string} message - The log message
13
+ * @returns {boolean} Returns false
14
+ * @private
15
+ */static err(xpFunction,message){return XpLog.log("error",xpFunction,message),!1}static warn(xpFunction,message){XpLog.log("warn",xpFunction,message)}}exports.XpLog=XpLog;class XpEvents{static eventCallback;static on(callbacks){XpEvents.eventCallback=callbacks}}exports.XpEvents=XpEvents;
@@ -0,0 +1,11 @@
1
+ import { User } from "../xp";
2
+ /**
3
+ * Get array of all users in the leaderboard
4
+ * @async
5
+ * @param {string?} guildId - Guild ID (optional)
6
+ * @param {number} limit - Limit of users to return
7
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/functions/leaderboard
8
+ * @returns {Promise<User[]>} Array of all users in the leaderboard
9
+ * @throws {XpFatal} If guild ID is not provided or limit is less than 1
10
+ */
11
+ export declare function leaderboard(guildId?: string, limit?: number): Promise<User[]>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Get array of all users in the leaderboard
4
+ * @async
5
+ * @param {string?} guildId - Guild ID (optional)
6
+ * @param {number} limit - Limit of users to return
7
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/functions/leaderboard
8
+ * @returns {Promise<User[]>} Array of all users in the leaderboard
9
+ * @throws {XpFatal} If guild ID is not provided or limit is less than 1
10
+ */async function leaderboard(guildId,limit){if(limit&&!(1<=limit))throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Limit must be a number greater than 0"});const e=new Set;return guildId=guildId?(await xp_1.db.find({collection:"simply-xps",data:{guild:guildId}})).sort((a,b)=>b.xp-a.xp):(await xp_1.db.findAll("simply-xps")).sort((a,b)=>b.xp-a.xp).filter(user=>!e.has(user.user)&&(e.add(user.user),!0)),await Promise.all(guildId.map(async(user,index)=>(user.position=index+1,user))),guildId.slice(0,limit)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.leaderboard=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp");exports.leaderboard=leaderboard;
@@ -0,0 +1,27 @@
1
+ import { MongoClient } from "mongodb";
2
+ import { Database } from "better-sqlite3";
3
+ /**
4
+ * Migration functions
5
+ * @class migrate
6
+ */
7
+ export declare class migrate {
8
+ /**
9
+ * Effortlessly migrate from discord-xp to simply-xp.
10
+ * @async
11
+ * @param {boolean} deleteOld - Delete old data after migration
12
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratediscord_xp
13
+ * @returns {Promise<boolean>} - Returns true if migration is successful
14
+ * @throws {XpLog.err} - If migration fails.
15
+ */
16
+ static discord_xp(deleteOld?: boolean): Promise<boolean>;
17
+ /**
18
+ * Effortlessly migrate from MongoDB to SQLite. (or vice versa)
19
+ * @async
20
+ * @param {"mongodb"|"sqlite"} dbType
21
+ * @param {Database | MongoClient} connection
22
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratefromdb
23
+ * @returns {Promise<boolean>} - Returns true if migration is successful
24
+ * @throws {XpFatal} - If parameters are not provided correctly
25
+ */
26
+ static fromDB(dbType: "mongodb" | "sqlite", connection: Database | MongoClient): Promise<boolean>;
27
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.migrate=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp"),connect_1=require("./connect");class migrate{
2
+ /**
3
+ * Effortlessly migrate from discord-xp to simply-xp.
4
+ * @async
5
+ * @param {boolean} deleteOld - Delete old data after migration
6
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratediscord_xp
7
+ * @returns {Promise<boolean>} - Returns true if migration is successful
8
+ * @throws {XpLog.err} - If migration fails.
9
+ */
10
+ static async discord_xp(deleteOld=!1){var e=await xp_1.db.getCollection("levels").find().toArray();xplogs_1.XpLog.debug("migrate.discord_xp()",`FOUND ${e.length} DOCUMENTS`);try{for(const r of e)await xp_1.db.findOne({collection:"simply-xps",data:{guild:r.guildID,user:r.userID}})||(await xp_1.db.createOne({collection:"simply-xps",data:{guild:r.guildID,user:r.userID,xp:r.xp,level:(0,xp_1.convertFrom)(r.xp,"xp")}}),deleteOld&&await xp_1.db.getCollection("levels").deleteOne({userID:r.userID,guildID:r.guildID}));return!0}catch(e){return xplogs_1.XpLog.err("migrate.discord_xp()",e),!1}}
11
+ /**
12
+ * Effortlessly migrate from MongoDB to SQLite. (or vice versa)
13
+ * @async
14
+ * @param {"mongodb"|"sqlite"} dbType
15
+ * @param {Database | MongoClient} connection
16
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratefromdb
17
+ * @returns {Promise<boolean>} - Returns true if migration is successful
18
+ * @throws {XpFatal} - If parameters are not provided correctly
19
+ */static async fromDB(dbType,connection){if(!dbType)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database type provided"});if(!connection)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database connection provided"});if(xp_1.xp.dbType===dbType)return xplogs_1.XpLog.info("migrate.fromDB()","Same database received, that was unnecessary!");let e;switch(dbType){case"mongodb":try{if(!await(0,connect_1.checkPackageVersion)("mongodb",4,6))return xplogs_1.XpLog.err("migrate.fromDB()","MongoDB V4 up to V6 is required");e=await connection.db().collection("simply-xps").find().toArray()}catch(e){return xplogs_1.XpLog.err("migrate.fromDB()",e),!1}break;case"sqlite":try{if(!await(0,connect_1.checkPackageVersion)("better-sqlite3",7,8))return xplogs_1.XpLog.err("migrate.fromDB()","better-sqlite3 V7 up to V8 is required");e=connection.prepare("SELECT * FROM `simply-xps`").all()}catch(e){return xplogs_1.XpLog.err("migrate.fromDB()",e),!1}}return xplogs_1.XpLog.debug("migrate.fromDB()",`FOUND ${e.length} RESULTS`),await Promise.all(e.map(async user=>await xp_1.db.findOne({collection:"simply-xps",data:{guild:user.guild,user:user.user}})?xp_1.db.updateOne({collection:"simply-xps",data:{guild:user.guild,user:user.user}},{collection:"simply-xps",data:{guild:user.guild,user:user.user,name:user.name,xp:user.xp,level:user.level}}):xp_1.db.createOne({collection:"simply-xps",data:{guild:user.guild,user:user.user,xp:user.xp,level:user.level}}))),!0}}exports.migrate=migrate;
@@ -0,0 +1,29 @@
1
+ import { UserResult } from "./functions/database";
2
+ import { XPResult } from "./add";
3
+ /**
4
+ * Add XP to a user
5
+ * @async
6
+ * @param {string} userId
7
+ * @param {string} guildId
8
+ * @param {number} level
9
+ * @param {string} username - Username to use if auto_create is enabled
10
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addlevel
11
+ * @returns {Promise<UserResult>} - Object of user data on success
12
+ * @throws {XpFatal} - If parameters are not provided correctly
13
+ */
14
+ export declare function removeLevel(userId: string, guildId: string, level: number, username?: string): Promise<UserResult>;
15
+ /**
16
+ * Add XP to a user.
17
+ * @async
18
+ * @param {string} userId - The ID of the user.
19
+ * @param {string} guildId - The ID of the guild.
20
+ * @param {number | {min: number, max: number}} xpData - The XP to add, can be a number or an object with min and max properties.
21
+ * @param {string} username - Username to use if auto_create is enabled.
22
+ * @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addxp
23
+ * @returns {Promise<XPResult>} - Object of user data on success.
24
+ * @throws {XpFatal} - If parameters are not provided correctly.
25
+ */
26
+ export declare function removeXP(userId: string, guildId: string, xpData: number | {
27
+ min: number;
28
+ max: number;
29
+ }, username?: string): Promise<XPResult>;