simply-xp 2.0.0-dev.4 → 2.0.0-dev.5
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.
- package/README.md +4 -4
- package/lib/src/Fonts/BalooBhaijaan-Regular.woff2 +0 -0
- package/lib/src/add.d.ts +2 -2
- package/lib/src/add.js +2 -2
- package/lib/src/cards.d.ts +68 -32
- package/lib/src/cards.js +23 -11
- package/lib/src/charts.d.ts +1 -1
- package/lib/src/charts.js +2 -2
- package/lib/src/connect.d.ts +5 -3
- package/lib/src/connect.js +8 -6
- package/lib/src/create.d.ts +1 -1
- package/lib/src/create.js +1 -1
- package/lib/src/deprecated/rank.d.ts +1 -1
- package/lib/src/deprecated/rank.js +2 -3
- package/lib/src/fetch.d.ts +3 -3
- package/lib/src/fetch.js +2 -2
- package/lib/src/functions/database.d.ts +15 -6
- package/lib/src/functions/database.js +15 -7
- package/lib/src/functions/utilities.d.ts +2 -2
- package/lib/src/functions/utilities.js +3 -3
- package/lib/src/leaderboard.d.ts +1 -1
- package/lib/src/leaderboard.js +2 -2
- package/lib/src/migrate.d.ts +2 -2
- package/lib/src/migrate.js +4 -4
- package/lib/src/reset.d.ts +1 -1
- package/lib/src/reset.js +1 -1
- package/lib/src/roleSetup.d.ts +3 -4
- package/lib/src/roleSetup.js +3 -3
- package/lib/src/set.d.ts +2 -2
- package/lib/src/set.js +2 -2
- package/lib/xp.d.ts +1 -1
- package/lib/xp.js +5 -4
- package/package.json +17 -14
- package/lib/src/Fonts/BalooBhaijaan-Regular.otf +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.npmjs.com/package/simply-xp)
|
|
13
13
|
[](https://www.codefactor.io/repository/github/abadima/simply-xp)
|
|
14
14
|
|
|
15
|
-
[](https://simplyxp.js.org)
|
|
15
|
+
[](https://simplyxp.js.org/docs/next/intro/)
|
|
16
16
|
[](https://discord.gg/hjhnjYJNHX)
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -45,6 +45,7 @@ yarn add simply-xp@dev
|
|
|
45
45
|
- Added `db` class for extended database functionality
|
|
46
46
|
- Added `leaderboardCard()` function
|
|
47
47
|
- Added `convertFrom()` function
|
|
48
|
+
- Added `compareCard` function
|
|
48
49
|
- Added `migrate` class
|
|
49
50
|
|
|
50
51
|
# 🎉 V2 Changes 🎉
|
|
@@ -63,8 +64,7 @@ yarn add simply-xp@dev
|
|
|
63
64
|
# ⚠️ V2 Breaking Changes ⚠️
|
|
64
65
|
|
|
65
66
|
- `create()` Now requires `username` argument.
|
|
66
|
-
- `charts()` Requires new arguments.
|
|
67
|
-
- `rank()` is **deprecated**, use `rankCard()` instead.
|
|
68
|
-
- `rankCard()` Requires completely new arguments.
|
|
67
|
+
- `charts()` Requires new arguments, and is revamped.
|
|
68
|
+
- `rank()` is **deprecated**, use `rankCard()` instead. (REQUIRES NEW ARGUMENTS)
|
|
69
69
|
- `roleSetup()` functions loses `client` argument.
|
|
70
70
|
- `leaderboard()` loses `client` argument, and returns `user` instead of `userID`
|
|
Binary file
|
package/lib/src/add.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { UserResult } from "./functions/database";
|
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {number} level
|
|
8
8
|
* @param {string} username - Username to use if auto_create is enabled
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/addlevel
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
12
|
*/
|
|
@@ -25,7 +25,7 @@ interface XPResult extends UserResult {
|
|
|
25
25
|
* @param {string} guildId - The ID of the guild.
|
|
26
26
|
* @param {number | {min: number, max: number}} xpData - The XP to add, can be a number or an object with min and max properties.
|
|
27
27
|
* @param {string} username - Username to use if auto_create is enabled.
|
|
28
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/addxp
|
|
28
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addxp
|
|
29
29
|
* @returns {Promise<XPResult>} - Object of user data on success.
|
|
30
30
|
* @throws {XpFatal} - If parameters are not provided correctly.
|
|
31
31
|
*/
|
package/lib/src/add.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {number} level
|
|
8
8
|
* @param {string} username - Username to use if auto_create is enabled
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/addlevel
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
12
|
*/async function addLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"addLevel()",message:"Level was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});if(e)return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:e.level+level,xp:(0,utilities_1.convertFrom)(level+e.level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"addLevel()",message:"User does not exist"})}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @param {string} guildId - The ID of the guild.
|
|
18
18
|
* @param {number | {min: number, max: number}} xpData - The XP to add, can be a number or an object with min and max properties.
|
|
19
19
|
* @param {string} username - Username to use if auto_create is enabled.
|
|
20
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/addxp
|
|
20
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/addxp
|
|
21
21
|
* @returns {Promise<XPResult>} - Object of user data on success.
|
|
22
22
|
* @throws {XpFatal} - If parameters are not provided correctly.
|
|
23
23
|
*/async function addXP(userId,guildId,xpData,username){if(!("number"==typeof xpData||"object"==typeof xp_1.xp&&xpData.min&&xpData.max))throw new xplogs_1.XpFatal({function:"addXP()",message:"XP is not a number or object, make sure you are using the correct syntax"});if("object"==typeof xpData&&(xpData=Math.floor(Math.random()*(xpData.max-xpData.min)+xpData.min)),!userId)throw new xplogs_1.XpFatal({function:"addXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addXP()",message:"Guild ID was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let a;if(e)a=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(e.xp+xpData,"xp"),xp:e.xp+xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"addXP()",message:"User does not exist"});a=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData,"xp"),xp:xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})})}return{...a,hasLevelledUp:!e||a.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.addXP=exports.addLevel=void 0;const utilities_1=require("./functions/utilities"),xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database"),xp_1=require("../xp");exports.addLevel=addLevel,exports.addXP=addXP;
|
package/lib/src/cards.d.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { SKRSContext2D } from "@napi-rs/canvas";
|
|
2
3
|
import { User } from "./leaderboard";
|
|
3
4
|
type HexColor = `#${string}` | `0x${string}`;
|
|
5
|
+
export type CompareCardLocales = {
|
|
6
|
+
level?: string;
|
|
7
|
+
versus?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @property {URL} background - Background image URL
|
|
11
|
+
* @property {HexColor} color - Avatar border color
|
|
12
|
+
* @property {HexColor} centerBar - Center bar color
|
|
13
|
+
* @property {HexColor} centerBarBg - Center bar background color
|
|
14
|
+
* @property {string} font - ABSOLUTE FILE PATH
|
|
15
|
+
* @property {boolean} light - Use light theme
|
|
16
|
+
*/
|
|
17
|
+
export interface CompareCardOptions {
|
|
18
|
+
background?: URL;
|
|
19
|
+
color?: HexColor;
|
|
20
|
+
centerBar?: HexColor;
|
|
21
|
+
centerBarBg?: HexColor;
|
|
22
|
+
font?: string;
|
|
23
|
+
light?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type LeaderboardCardLocales = {
|
|
26
|
+
level?: string;
|
|
27
|
+
members?: string;
|
|
28
|
+
};
|
|
4
29
|
/**
|
|
5
30
|
* @property {[HexColor, HexColor]} artworkColors - Gradient colors
|
|
6
31
|
* @property {URL} artworkImage
|
|
@@ -10,7 +35,7 @@ type HexColor = `#${string}` | `0x${string}`;
|
|
|
10
35
|
* @property {string} font - ABSOLUTE FILE PATH
|
|
11
36
|
* @property {boolean} light - Use light theme
|
|
12
37
|
*/
|
|
13
|
-
export interface
|
|
38
|
+
export interface LeaderboardCardOptions {
|
|
14
39
|
artworkColors?: [HexColor, HexColor];
|
|
15
40
|
artworkImage?: URL;
|
|
16
41
|
borderColors?: [HexColor, HexColor];
|
|
@@ -19,9 +44,14 @@ export interface LeaderboardOptions {
|
|
|
19
44
|
font?: string;
|
|
20
45
|
light?: boolean;
|
|
21
46
|
}
|
|
47
|
+
export type RankCardLocales = {
|
|
48
|
+
level?: string;
|
|
49
|
+
next_level?: string;
|
|
50
|
+
xp?: string;
|
|
51
|
+
};
|
|
22
52
|
/**
|
|
23
53
|
* @property {URL} background - Background image URL
|
|
24
|
-
* @property {HexColor} color
|
|
54
|
+
* @property {HexColor} color - Avatar border color
|
|
25
55
|
* @property {boolean} legacy - Use legacy card design
|
|
26
56
|
* @property {HexColor} lvlbar
|
|
27
57
|
* @property {HexColor} lvlbarBg
|
|
@@ -31,39 +61,32 @@ export interface RankCardOptions {
|
|
|
31
61
|
background?: URL;
|
|
32
62
|
color?: HexColor;
|
|
33
63
|
legacy?: boolean;
|
|
64
|
+
light?: boolean;
|
|
34
65
|
lvlbar?: HexColor;
|
|
35
66
|
lvlbarBg?: HexColor;
|
|
36
67
|
font?: string;
|
|
37
68
|
}
|
|
38
|
-
export type
|
|
69
|
+
export type CardUserOptions = {
|
|
39
70
|
id: string;
|
|
40
71
|
username: string;
|
|
41
72
|
avatarURL: string;
|
|
42
73
|
};
|
|
43
|
-
export type LeaderboardLocales = {
|
|
44
|
-
level?: string;
|
|
45
|
-
members?: string;
|
|
46
|
-
};
|
|
47
|
-
export type rankLocales = {
|
|
48
|
-
level?: string;
|
|
49
|
-
next_level?: string;
|
|
50
|
-
xp?: string;
|
|
51
|
-
};
|
|
52
74
|
/**
|
|
53
|
-
* Generate a simple
|
|
75
|
+
* Generate a simple comparison card
|
|
54
76
|
* @async
|
|
55
77
|
* @param {{id: string, name: string}} guild - (id, name)
|
|
56
|
-
* @param {
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
78
|
+
* @param {CardUserOptions} user1 - User 1
|
|
79
|
+
* @param {CardUserOptions} user2 - User 2
|
|
80
|
+
* @param {CompareCardOptions?} options - (background, color, legacy, lvlbar, lvlbarBg, font)
|
|
81
|
+
* @param {CompareCardLocales?} locales - [BETA] Translate the rank card
|
|
82
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/compareCard
|
|
60
83
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
61
|
-
* @throws {XpFatal} - If parameters are not provided correctly
|
|
84
|
+
* @throws {XpFatal} - If parameters are not provided correctly or if the user is not found in the database
|
|
62
85
|
*/
|
|
63
|
-
export declare function
|
|
86
|
+
export declare function compareCard(guild: {
|
|
64
87
|
id: string;
|
|
65
88
|
name: string;
|
|
66
|
-
},
|
|
89
|
+
}, user1: CardUserOptions, user2: CardUserOptions, options?: CompareCardOptions, locales?: CompareCardLocales): Promise<{
|
|
67
90
|
attachment: Buffer;
|
|
68
91
|
description: string;
|
|
69
92
|
name: string;
|
|
@@ -72,18 +95,37 @@ export declare function rankCard(guild: {
|
|
|
72
95
|
* Generate a simple leaderboard card
|
|
73
96
|
* @async
|
|
74
97
|
* @param {Array<User>} data - Array of user data
|
|
75
|
-
* @param {
|
|
98
|
+
* @param {LeaderboardCardOptions?} options - (artworkColor, artworkImage, light)
|
|
76
99
|
* @param {{name: string, imageURL: string, memberCount: number}?} guildInfo - Guild info
|
|
77
|
-
* @param {
|
|
78
|
-
* @link
|
|
100
|
+
* @param {LeaderboardCardLocales?} locales - Locales
|
|
101
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/leaderboard
|
|
79
102
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
80
103
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
81
104
|
*/
|
|
82
|
-
export declare function leaderboardCard(data: Array<User>, options?:
|
|
105
|
+
export declare function leaderboardCard(data: Array<User>, options?: LeaderboardCardOptions, guildInfo?: {
|
|
83
106
|
name: string;
|
|
84
107
|
imageURL: string;
|
|
85
108
|
memberCount: number;
|
|
86
|
-
}, locales?:
|
|
109
|
+
}, locales?: LeaderboardCardLocales): Promise<{
|
|
110
|
+
attachment: Buffer;
|
|
111
|
+
description: string;
|
|
112
|
+
name: string;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Generate a simple user rank card
|
|
116
|
+
* @async
|
|
117
|
+
* @param {{id: string, name: string}} guild - (id, name)
|
|
118
|
+
* @param {CardUserOptions} user - (id, username, avatarURL)
|
|
119
|
+
* @param {RankCardOptions?} options - (background, color, legacy, lvlbar, lvlbarBg, font)
|
|
120
|
+
* @param {RankCardLocales?} locales - [BETA] Translate the rank card
|
|
121
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/rankCard
|
|
122
|
+
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
123
|
+
* @throws {XpFatal} - If parameters are not provided correctly
|
|
124
|
+
*/
|
|
125
|
+
export declare function rankCard(guild: {
|
|
126
|
+
id: string;
|
|
127
|
+
name: string;
|
|
128
|
+
}, user: CardUserOptions, options?: RankCardOptions, locales?: RankCardLocales): Promise<{
|
|
87
129
|
attachment: Buffer;
|
|
88
130
|
description: string;
|
|
89
131
|
name: string;
|
|
@@ -92,13 +134,7 @@ export declare function leaderboardCard(data: Array<User>, options?: Leaderboard
|
|
|
92
134
|
* @constructor
|
|
93
135
|
* @private
|
|
94
136
|
*/
|
|
95
|
-
export declare function RoundedBox(ctx: {
|
|
96
|
-
beginPath: () => void;
|
|
97
|
-
moveTo: (arg0: number, arg1: number) => void;
|
|
98
|
-
lineTo: (arg0: number, arg1: number) => void;
|
|
99
|
-
quadraticCurveTo: (arg0: number, arg1: number, arg2: number, arg3: number) => void;
|
|
100
|
-
closePath: () => void;
|
|
101
|
-
}, x: number, y: number, width: number, height: number, radius: number, roundCorners?: {
|
|
137
|
+
export declare function RoundedBox(ctx: SKRSContext2D, x: number, y: number, width: number, height: number, radius: number, strokeColor?: string, roundCorners?: {
|
|
102
138
|
top?: boolean;
|
|
103
139
|
bottom?: boolean;
|
|
104
140
|
}): void;
|
package/lib/src/cards.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Generate a simple
|
|
3
|
+
* Generate a simple comparison card
|
|
4
4
|
* @async
|
|
5
5
|
* @param {{id: string, name: string}} guild - (id, name)
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @
|
|
6
|
+
* @param {CardUserOptions} user1 - User 1
|
|
7
|
+
* @param {CardUserOptions} user2 - User 2
|
|
8
|
+
* @param {CompareCardOptions?} options - (background, color, legacy, lvlbar, lvlbarBg, font)
|
|
9
|
+
* @param {CompareCardLocales?} locales - [BETA] Translate the rank card
|
|
10
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/compareCard
|
|
10
11
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
11
|
-
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
|
-
*/async function
|
|
12
|
+
* @throws {XpFatal} - If parameters are not provided correctly or if the user is not found in the database
|
|
13
|
+
*/async function compareCard(guild,user1,user2,options={},locales={}){var e,a,o,t,r,l;if(!guild?.id||!guild?.name)throw new xplogs_1.XpFatal({function:"compareCard()",message:"Please provide a guild"});if(!(user1?.id&&user1?.username&&user2?.id&&user2?.username))throw new xplogs_1.XpFatal({function:"compareCard()",message:"Please provide two valid users!"});if(!user1?.avatarURL.endsWith(".png")&&!user1.avatarURL.endsWith(".jpg")&&!user1.avatarURL.endsWith(".webp"))throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 1] Avatar image must be a png, jpg, or webp"});if(!user2?.avatarURL.endsWith(".png")&&!user2.avatarURL.endsWith(".jpg")&&!user2.avatarURL.endsWith(".webp"))throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 2] Avatar image, avatar image must be a png, jpg, or webp"});canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.woff2"),"Sans Serif"),locales?.level||(locales.level="Level"),locales?.versus||(locales.versus="vs"),t=await(0,canvas_1.loadImage)(options?.background||"https://i.ibb.co/WnfXZjc/clouds.jpg").catch(()=>{throw new xplogs_1.XpFatal({function:"compareCard()",message:"Unable to load background image, is it valid?"})}),e=await(0,canvas_1.loadImage)(user1.avatarURL).catch(()=>{throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 1] Unable to load user's AvatarURL, is it reachable?"})}),a=await(0,canvas_1.loadImage)(user2.avatarURL).catch(()=>{throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 2] Unable to load user's AvatarURL, is it reachable?"})});let n=await database_1.db.findOne({collection:"simply-xps",data:{guild:guild.id,user:user1.id}});if(!n){if(!xp_1.xp.auto_create||!user2?.username)throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 1] User not found in database"});n=await(0,xp_1.create)(user1.id,guild.id,user1.username)}let s=await database_1.db.findOne({collection:"simply-xps",data:{guild:guild.id,user:user2.id}});if(!s){if(!xp_1.xp.auto_create||!user2?.username)throw new xplogs_1.XpFatal({function:"compareCard()",message:"[USER 2] User not found in database"});s=await(0,xp_1.create)(user2.id,guild.id,user2.username)}return RoundedBox(o=(guild=(0,canvas_1.createCanvas)(1080,400)).getContext("2d"),0,0,guild.width,guild.height,25),o.clip(),o.globalAlpha=.2,o.fillStyle=options?.light?"#ffffff":"#000000",o.fill(),o.globalAlpha=.5,o.drawImage(t,-5,0,1090,400),o.restore(),o.globalAlpha=1,t=user1.username.replace(/[\u007f-\uffff]/g,""),user1=user2.username.replace(/[\u007f-\uffff]/g,""),user2=options?.color||"rgba(255,255,255,0.5)",options=options?.centerBarBg||options?.light?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",r=locales.level+(" "+shortener(n.level)),l=locales.level+(" "+shortener(s.level)),o.save(),o.textAlign="center",o.fillStyle="#ffffff",o.shadowColor="#000000",o.shadowBlur=6,o.shadowOffsetX=1,o.shadowOffsetY=1,o.font='39px "Sans Serif"',o.fillText(`${t} ${locales.versus} `+user1,540,60),o.restore(),o.save(),o.beginPath(),o.arc(160,200,100,0,2*Math.PI,!0),o.closePath(),o.strokeStyle=user2,o.lineWidth=15,o.stroke(),o.clip(),o.drawImage(e,50,90,220,220),o.restore(),o.save(),o.beginPath(),o.arc(920,200,100,0,2*Math.PI,!0),o.closePath(),o.strokeStyle=user2,o.lineWidth=15,o.stroke(),o.clip(),o.drawImage(a,810,90,220,220),o.restore(),o.save(),o.globalAlpha=1,o.fillStyle="#ffffff",o.textAlign="center",o.font='25px "Sans Serif"',o.fillText(r,160,350),o.fillText(l,920,350),o.restore(),o.save(),o.globalAlpha=1,RoundedBox(o,265,330,540,25,10),o.clip(),o.fillStyle=options,o.fill(),{attachment:guild.toBuffer("image/png"),description:"Simply-XP Comparison Card",name:"compareCard.png"}}
|
|
13
14
|
/**
|
|
14
15
|
* Generate a simple leaderboard card
|
|
15
16
|
* @async
|
|
16
17
|
* @param {Array<User>} data - Array of user data
|
|
17
|
-
* @param {
|
|
18
|
+
* @param {LeaderboardCardOptions?} options - (artworkColor, artworkImage, light)
|
|
18
19
|
* @param {{name: string, imageURL: string, memberCount: number}?} guildInfo - Guild info
|
|
19
|
-
* @param {
|
|
20
|
-
* @link
|
|
20
|
+
* @param {LeaderboardCardLocales?} locales - Locales
|
|
21
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/leaderboard
|
|
22
|
+
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
23
|
+
* @throws {XpFatal} - If parameters are not provided correctly
|
|
24
|
+
*/async function leaderboardCard(data,options={},guildInfo,locales={}){var e,a;if(!data||data.length<1)throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"There must be at least 1 user in the data array"});!cachedLeaderboardArtwork&&options?.artworkImage&&(cachedLeaderboardArtwork=await(0,canvas_1.loadImage)(options.artworkImage).catch(()=>{throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"Unable to load artwork image, is it valid?"})})),!cachedLeaderboardImage&&options?.backgroundImage&&(cachedLeaderboardImage=await(0,canvas_1.loadImage)(options.backgroundImage).catch(()=>{throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"Unable to load background image, is it valid?"})})),canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.woff2"),"Sans Serif"),locales.level||(locales.level="LEVEL"),locales.members||(locales.members="Members"),data=data.slice(0,8);let o,t,r,l=(r=options?.light?{artworkColors:options?.artworkColors||["#374bff","#5f69ff"],backgroundColor:"#f0f0eb",borderColors:options?.borderColors||["#ffa237","#ffcc6b"],evenColor:"#dcdcdc",oddColor:"#c8c8c8",primaryTextColor:"#000000",secondaryTextColor:"rgba(0,0,0,0.5)"}:{artworkColors:options?.artworkColors||["#374bff","#333793"],backgroundColor:"#141414",borderColors:options?.borderColors||["#ffa237","#b67125"],evenColor:"#1e1e1e",oddColor:"#282828",primaryTextColor:"#ffffff",secondaryTextColor:"rgba(255,255,255,0.5)"},cachedLeaderboardCanvas&&cachedLeaderboardContext?(o=cachedLeaderboardCanvas,t=cachedLeaderboardContext):(o=(0,canvas_1.createCanvas)(1350,1080),RoundedBox(t=o.getContext("2d"),0,0,o.width,o.height,20),t.clip(),(e=t.createLinearGradient(0,0,o.width,0)).addColorStop(0,r.artworkColors[0]),e.addColorStop(1,r.artworkColors[1]),t.fillStyle=e,t.fillRect(0,0,o.width,220),cachedLeaderboardArtwork&&(t.fillStyle="#000000",t.fillRect(0,0,o.width,220),t.globalAlpha=.5,t.drawImage(cachedLeaderboardArtwork,0,0,o.width,220),t.globalAlpha=1),t.fillStyle=options.backgroundColor||r.backgroundColor,t.fillRect(0,220,o.width,1080),cachedLeaderboardImage&&(t.globalAlpha=.9,t.drawImage(cachedLeaderboardImage,0,220,o.width,1080),t.globalAlpha=1)),guildInfo&&guildInfo?.imageURL&&guildInfo?.name&&guildInfo?.memberCount&&(e=await(0,canvas_1.loadImage)(guildInfo.imageURL),t.save(),t.beginPath(),t.arc(150,110,90,0,2*Math.PI,!0),t.closePath(),t.clip(),t.drawImage(e,60,20,180,180),t.restore(),(options=t.createLinearGradient(0,0,0,220)).addColorStop(0,r.borderColors[0]),options.addColorStop(1,r.borderColors[1]),t.strokeStyle=options,t.lineWidth=10,t.beginPath(),t.arc(150,110,90,0,2*Math.PI,!0),t.stroke(),t.fillStyle=r.primaryTextColor,t.font='60px "Sans Serif"',t.fillText(guildInfo.name,270,110),t.fillStyle=r.secondaryTextColor,t.font='40px "Sans Serif"',t.fillText(guildInfo.memberCount+" "+locales.members,270,160)),r.evenColor);for(let e=0;e<data.length;e++)a=300+90*e,1===data.length?RoundedBox(t,30,a,1290,90,20):0===e?RoundedBox(t,30,a,1290,90,20,void 0,{top:!0,bottom:!1}):e===data.length-1?RoundedBox(t,30,a,1290,90,20,void 0,{top:!1,bottom:!0}):RoundedBox(t,30,a,1290,90,0),t.fillStyle=l,t.globalAlpha=cachedLeaderboardImage?.5:1,t.fill(),t.globalAlpha=1,t.textAlign="left",t.font='30px "Sans Serif"',t.fillStyle=r.secondaryTextColor,t.fillText(e+1+".",60,55+a),t.textAlign="left",t.font='40px "Sans Serif"',t.fillStyle=r.primaryTextColor,t.fillText(data[e]?.name||data[e]?.user||"???",120,60+a),t.textAlign="right",t.font='30px "Sans Serif"',t.fillStyle=r.primaryTextColor,t.fillText(shortener(data[e]?.level)||"???",1270,55+a),t.fillStyle=r.secondaryTextColor,t.fillText(locales.level,1270-t.measureText(shortener(data[e]?.level)||"???").width-15,55+a),l=l===r.evenColor?r.oddColor:r.evenColor;return{attachment:o.toBuffer("image/png"),description:"Simply-XP Leaderboard Card",name:"leaderboard.png"}}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a simple user rank card
|
|
27
|
+
* @async
|
|
28
|
+
* @param {{id: string, name: string}} guild - (id, name)
|
|
29
|
+
* @param {CardUserOptions} user - (id, username, avatarURL)
|
|
30
|
+
* @param {RankCardOptions?} options - (background, color, legacy, lvlbar, lvlbarBg, font)
|
|
31
|
+
* @param {RankCardLocales?} locales - [BETA] Translate the rank card
|
|
32
|
+
* @link `Documentation` https://simplyxp.js.org/docs/next/functions/rankCard
|
|
21
33
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
22
34
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
23
|
-
*/async function
|
|
35
|
+
*/async function rankCard(guild,user,options={},locales={}){var e,a,o,t,r,l,n,s,i,d,f;if(!guild)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No Guild Provided"});if(!user)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No User Provided"});let c,p;if(locales?.level||(locales.level="Level"),locales?.next_level||(locales.next_level="Next Level"),locales?.xp||(locales.xp="XP"),xplogs_1.XpLog.debug("rankCard()",`${options?.legacy?"LEGACY":"MODERN"} ENABLED`),!user?.avatarURL.endsWith(".png")&&!user.avatarURL.endsWith(".jpg")&&!user.avatarURL.endsWith(".webp"))throw new xplogs_1.XpFatal({function:"rankCard()",message:"Invalid avatar image, avatar image must be a png, jpg, or webp"});if(!user||!user.id||!user.username)throw new xplogs_1.XpFatal({function:"rankCard()",message:"Invalid User Provided, user must contain id, username, and avatarURL."});canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.woff2"),"Sans Serif"),cachedRankImage=cachedRankImage||await(0,canvas_1.loadImage)(options?.background||(options?.legacy?"https://i.ibb.co/dck2Tnt/rank-card.webp":"https://i.ibb.co/WnfXZjc/clouds.jpg")).catch(()=>{throw new xplogs_1.XpFatal({function:"rankCard()",message:"Unable to load background image, is it valid?"})}),e=await(0,canvas_1.loadImage)(user.avatarURL).catch(()=>{throw new xplogs_1.XpFatal({function:"rankCard()",message:"Unable to load user's AvatarURL, is it reachable?"})});let g=await database_1.db.findOne({collection:"simply-xps",data:{guild:guild.id,user:user.id}});if(!g){if(!xp_1.xp.auto_create)throw new xplogs_1.XpFatal({function:"rankCard()",message:"User not found in database"});g=await(0,xp_1.create)(user.id,guild.id,user.username)}return a=await database_1.db.find({collection:"simply-xps",data:{guild:guild.id}}),g.position=a.sort((a,b)=>b.xp-a.xp).findIndex(u=>u.user===user.id)+1,cachedRankContext&&cachedRankCanvas?(c=cachedRankCanvas,p=cachedRankContext):(c=(0,canvas_1.createCanvas)(1080,400),RoundedBox(p=c.getContext("2d"),0,0,c.width,c.height,25),p.clip(),options?.legacy?(p.globalAlpha=1,p.fillStyle="#000000",p.fill()):(p.globalAlpha=.2,p.fillStyle=options?.light?"#ffffff":"#000000",p.fill(),p.globalAlpha=.5),p.drawImage(cachedRankImage,-5,0,1090,400),p.restore()),a=user.username.replace(/[\u007f-\uffff]/g,""),o=options?.color||(options?.legacy?"#9900ff":"rgba(255,255,255,0.5)"),t=options?.lvlbar||"#ffffff",r=options?.lvlbarBg||options?.legacy?"#FFFFFF":options?.light?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",l=shortener(g.xp)+(" "+locales.xp),n=locales.level+(" "+shortener(g.level)),s="{current} / {needed}",i=(0,utilities_1.convertFrom)(g.level+1),d=(0,utilities_1.convertFrom)(g.level),d=100*(g.xp-d)/(i-d)*(options?.legacy?660:530)/100,f="326815959358898189"===g.user?"#ade6d8":1===g.position?"#ADD8E6":2===g.position?"#C0C0C0":3===g.position?"#CD7F32":"#ffffff",p.save(),options?.legacy?(p.fillStyle="#000000",p.globalAlpha=.4,p.fillRect(40,0,240,c.height),p.globalAlpha=1,RoundedBox(p,70,30,180,180,50),p.strokeStyle=o,p.lineWidth=15,p.stroke(),p.clip(),p.drawImage(e,70,30,180,180),p.restore(),p.save(),RoundedBox(p,70,320,180,50,20,"#BFC85A22"),p.fillStyle=o,p.globalAlpha=1,p.fillRect(70,320,180,50),p.globalAlpha=1,p.fillStyle="#ffffff",p.textAlign="center",dynamicFont(p,l,160,358,160,32),p.restore(),p.save(),RoundedBox(p,70,240,180,50,20,"#BFC85A22"),p.fillStyle=o,p.globalAlpha=1,p.fillRect(70,240,180,50),p.globalAlpha=1,p.fillStyle="#ffffff",p.textAlign="center",dynamicFont(p,n,160,278,160,32),p.restore(),p.save(),p.textAlign="left",p.fillStyle="#ffffff",p.shadowColor="#000000",p.shadowBlur=15,p.shadowOffsetX=1,p.shadowOffsetY=1,p.font='39px "Sans Serif"',p.fillText(a,390,80),p.restore(),p.save(),p.textAlign="right",p.fillStyle="#ffffff",p.shadowColor="#000000",p.shadowBlur=15,p.shadowOffsetX=1,p.shadowOffsetY=1,p.font='55px "Sans Serif"',p.fillText("#"+g.position,c.width-55,80),p.restore(),p.save(),RoundedBox(p,390,305,660,70,20,"#BFC85A22"),p.fillStyle="#ffffff",p.textAlign="center",dynamicFont(p,guild.name,720,355,700,45),p.globalAlpha=.2,p.fillRect(390,305,660,70),p.restore(),p.save(),RoundedBox(p,390,145,660,50,20,"#BFC85A22"),p.fillStyle=r,p.globalAlpha=.2,p.fillRect(390,145,660,50),p.restore(),p.save(),RoundedBox(p,390,145,d,50,20,"#BFC85A22"),p.fillStyle=t,p.globalAlpha=.5,p.fillRect(390,145,d,50),p.restore(),p.save(),p.textAlign="left",p.fillStyle="#ffffff",p.globalAlpha=.8,p.font='30px "Sans Serif"',p.fillText(locales.next_level+": "+shortener(i)+" "+locales.xp,390,230),p.restore(),options=s.replace(/{needed}/g,shortener(i)).replace(/{current}/g,shortener(g.xp)),p.textAlign="center",p.fillStyle="#474747",p.globalAlpha=1,p.font='30px "Sans Serif"',p.fillText(options,730,180)):(p.globalAlpha=1,p.save(),p.textAlign="center",p.fillStyle="#ffffff",p.shadowColor="#000000",p.shadowBlur=5,p.shadowOffsetX=1,p.shadowOffsetY=1,p.font='39px "Sans Serif"',p.fillText(a,540,80),p.restore(),p.save(),p.beginPath(),p.arc(160,200,100,0,2*Math.PI,!0),p.closePath(),p.strokeStyle=o,p.lineWidth=15,p.stroke(),p.clip(),p.drawImage(e,50,90,220,220),p.restore(),p.save(),p.beginPath(),p.arc(230,130,30,0,2*Math.PI,!0),p.closePath(),p.strokeStyle=o,p.lineWidth=5,p.stroke(),p.clip(),p.beginPath(),p.arc(230,130,30,0,2*Math.PI,!0),p.closePath(),p.fillStyle=f,p.fill(),p.clip(),p.fillStyle="#000000",p.textAlign="center",p.font='25px "Sans Serif"',p.fillText(shortener(g.position,!0),230,138),p.restore(),p.save(),p.fillStyle="#ffffff",p.font='25px "Sans Serif"',p.textAlign="center",p.globalAlpha=1,p.fillText(n,160,350),p.restore(),p.save(),p.globalAlpha=1,RoundedBox(p,265,330,540,25,10),p.clip(),p.fillStyle=r,p.fill(),RoundedBox(p,270,335,d,15,5),p.fillStyle=t,p.fill(),p.restore(),p.save(),p.textAlign="center",p.fillStyle="#ffffff",p.globalAlpha=.6,p.font='20px "Sans Serif"',p.fillText(s.replace(/{needed}/g,shortener(i)).replace(/{current}/g,shortener(g.xp)),540,320),p.save(),p.fillStyle="#ffffff",p.textAlign="center",p.globalAlpha=1,p.font='25px "Sans Serif"',p.fillText(locales.level+" "+shortener(g.level+1),920,350),p.restore()),{attachment:c.toBuffer("image/png"),description:"Simply-XP Rank Card",name:"rank.png"}}function RoundedBox(ctx,x,y,width,height,radius,strokeColor,roundCorners={top:!0,bottom:!0}){ctx.beginPath(),ctx.moveTo(x+(roundCorners.top?radius:0),y),ctx.lineTo(x+width-(roundCorners.top?radius:0),y),roundCorners.top&&ctx.quadraticCurveTo(x+width,y,x+width,y+radius),ctx.lineTo(x+width,y+height-(roundCorners.bottom?radius:0)),roundCorners.bottom&&ctx.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),ctx.lineTo(x+(roundCorners.bottom?radius:0),y+height),roundCorners.bottom&&ctx.quadraticCurveTo(x,y+height,x,y+height-radius),ctx.lineTo(x,y+(roundCorners.top?radius:0)),roundCorners.top&&ctx.quadraticCurveTo(x,y,x+radius,y),ctx.closePath(),strokeColor&&(ctx.strokeStyle=strokeColor,ctx.stroke(),ctx.clip())}function shortener(count,roundedNumber){let e="",a=0;if(!count||0===count)return"0";if(count===1/0)return"∞";for(;1e3<=count&&a<8;)count/=1e3,a++;switch(a){case 1:e="K";break;case 2:e="M";break;case 3:e="B";break;case 4:e="T";break;case 5:e="Qa";break;case 6:e="Qi";break;case 7:e="Sx";break;case 8:e="Sp"}return""+count.toFixed(0===a||roundedNumber?0:2)+e}function dynamicFont(context,text,x,y,maxWidth,maxSize){let e=maxSize;for(;0<e&&(context.font=e+'px "Sans Serif"',!(context.measureText(text).width<maxWidth));)e--;context.textAlign="center",context.fillText(text,x,y)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.RoundedBox=exports.rankCard=exports.leaderboardCard=exports.compareCard=void 0;const canvas_1=require("@napi-rs/canvas"),xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database"),utilities_1=require("./functions/utilities"),path_1=require("path"),xp_1=require("../xp");let cachedRankImage,cachedRankCanvas,cachedRankContext,cachedLeaderboardArtwork,cachedLeaderboardCanvas,cachedLeaderboardContext,cachedLeaderboardImage;exports.compareCard=compareCard,exports.leaderboardCard=leaderboardCard,exports.rankCard=rankCard,exports.RoundedBox=RoundedBox;
|
package/lib/src/charts.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ChartOptions {
|
|
|
16
16
|
* @async
|
|
17
17
|
* @param {string} guildId
|
|
18
18
|
* @param {ChartOptions?} options
|
|
19
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/charts
|
|
19
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/charts
|
|
20
20
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>} Chart attachment
|
|
21
21
|
* @throws {XpFatal} If invalid parameters are provided, or if there are not enough users to create a chart
|
|
22
22
|
*/
|
package/lib/src/charts.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @async
|
|
5
5
|
* @param {string} guildId
|
|
6
6
|
* @param {ChartOptions?} options
|
|
7
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/charts
|
|
7
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/charts
|
|
8
8
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>} Chart attachment
|
|
9
9
|
* @throws {XpFatal} If invalid parameters are provided, or if there are not enough users to create a chart
|
|
10
|
-
*/async function charts(guildId,options={}){var t,r,a,
|
|
10
|
+
*/async function charts(guildId,options={}){var F,t,o,r,a,i,l,s,e;if(!guildId)throw new xplogs_1.XpFatal({function:"charts()",message:"No Guild ID Provided"});if(!options)throw new xplogs_1.XpFatal({function:"charts()",message:"No Options Provided"});options.theme&&["blue","dark","discord","green","orange","red","space","yellow"].includes(options.theme)||(xplogs_1.XpLog.warn("charts()","Invalid theme provided, defaulting to discord"),options.theme="discord"),options.type&&["bar","doughnut","pie"].includes(options.type)||(xplogs_1.XpLog.warn("charts()","Invalid type provided, defaulting to bar chart"),options.type="bar");let n={background:"#FFFFFF",barColor:"#FFFFFF",pieColors:["#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"],textColor:"#FFFFFF"};if((F=await(0,leaderboard_1.leaderboard)(guildId,Math.min(Math.max(options?.limit||10,2),10)).catch(XPError=>{throw new xplogs_1.XpFatal({function:"charts()",message:XPError.message})})).length<2)throw new xplogs_1.XpFatal({function:"charts()",message:"Not enough users to create a chart"});switch(F.sort((a,b)=>b.position-a.position),canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.woff2"),"Sans Serif"),options.theme){case"blue":n={background:"#1e1e3c",barColor:"#747fff",pieColors:["#747fff","#2832C2","#59788E","#00d2e7","#281E5D","#a9f5ff","#000e3f","#30edc2","#186c84","#0098ff"],textColor:"#FFFFFF"};break;case"dark":n={background:"#1e1e1e",barColor:"#747474",pieColors:["#1B1D1F","#454C53","#72787F","#999999","#9EA4AA","#CCCCCC","#C9CDD2","#DEDEDE","#E8EBED","#FFFFFF"],textColor:"#FFFFFF"};break;case"discord":n={background:"#36393f",barColor:"#5865F2",pieColors:["#5865F2","#57F287","#FEE75C","#EB459E","#ED4245","#FFFFFF","#000000","#FAA61A","#C04DF9","#00AAFF"],textColor:"#FFFFFF"};break;case"green":n={background:"#1e321e",barColor:"#74ff7f",pieColors:["#00FF00","#008000","#7FFF00","#32CD32","#228B22","#006400","#9ACD32","#00FA9A","#ADFF2F","#7CFC00"],textColor:"#FFFFFF"};break;case"orange":n={background:"#321e1e",barColor:"#ff9f74",pieColors:["#FF8C00","#FF5E0E","#FF4500","#FF6347","#E26310","#F5761A","#FD673A","#FFA500","#FF7F50","#FFD700"],textColor:"#FFFFFF"};break;case"red":n={background:"#321e1e",barColor:"#ff7474",pieColors:["#FF0000","#FF2400","#FF4500","#FF6347","#FF7F50","#FF8C00","#FFA07A","#FFA500","#FFC0CB","#FFD700"],textColor:"#FFFFFF"};break;case"space":n={background:"#001F3F",barColor:"#192E5B",pieColors:["#192E5B","#1F3F7F","#264FA3","#2C5FC7","#337FEA","#3D8FFF","#4D9FFF","#5DAFFF","#6DBFFF","#7DCFFF"],textColor:"#FFFFFF"};break;case"yellow":n={background:"#32321e",barColor:"#ffff74",pieColors:["#FFFD37","#FFEF00","#FDFF00","#DAA520","#F4C430","#E4D00A","#D2B55B","#FFFFE0","#FFFACD","#F5DEB3"],textColor:"#FFFFFF"}}const d=(0,canvas_1.createCanvas)(920,600),h=d.getContext("2d"),c=Math.max(...F.map(user=>user.level));if((0,cards_1.RoundedBox)(h,0,0,d.width,d.height,25),h.clip(),h.fillStyle=n.background,h.fillRect(0,0,d.width,d.height),"space"===options.theme){h.clearRect(0,0,d.width,d.height),(guildId=h.createRadialGradient(d.width/2,d.height/2,1,d.width/2,d.height/2,Math.max(d.width,d.height))).addColorStop(0,"#000000"),guildId.addColorStop(1,"#001F3F"),h.fillStyle=guildId,h.fillRect(0,0,d.width,d.height),(guildId=h.createRadialGradient(150,150,10,150,150,100)).addColorStop(0,"#F2F2F2"),guildId.addColorStop(.8,"#D3D3D3"),guildId.addColorStop(1,"#001F3F"),h.fillStyle=guildId,h.beginPath(),h.arc(150,150,100,0,2*Math.PI),h.fill(),t=["#6B6B6B","#AA8F00","#473E83","#456579"];for(let e=0;e<t.length;e++)o=Math.random()*d.width,r=Math.random()*d.height,a=50*Math.random()+30,h.beginPath(),h.arc(o,r,a,0,2*Math.PI),h.fillStyle=t[e]||"#FFFFFF",h.fill();h.filter="blur(5px)",h.drawImage(d,0,0),h.filter="none";for(let e=0;e<100;e++)i=Math.random()*d.width,l=Math.random()*d.height,s=2*Math.random(),h.beginPath(),h.arc(i,l,s,0,2*Math.PI),h.fillStyle="#FFFFFF",h.fill()}let u=d.width-40,p=d.height-40;switch(options.type){case"bar":{e=h.measureText(c.toString()).width,u=d.width-e-60-40,p=d.height-100-40;const f=u/F.length-20,g=20+e+40,C=d.height-50-20;await Promise.all(F.map(async(user,index)=>{var e,F,t=user.level/c*p,index=g+index*(20+f),o=C-t,t=(h.fillStyle=n.barColor,h.strokeStyle=n.barColor,h.lineWidth=2,(0,cards_1.RoundedBox)(h,index,o,f,t,10),h.fill(),h.stroke(),index+f/2),index=(h.fillStyle=n.textColor,h.font="22px Sans Serif",user.level.toString()),r=h.measureText(index).width,o=o-10,index=(h.fillText(index,t-r/2,o),user?.name||user.user),r=h.measureText(index).width,o=(h.font=Math.min(Math.floor(f/r*16),18)+"px Sans Serif",r=h.measureText(index).width,30+C);"space"===options.theme&&(e=t-(user=r+10)/2,F=o-18,h.fillStyle="rgba(0, 0, 0, 0.5)",h.fillRect(e,F,user,22)),h.fillStyle=n.textColor,h.fillText(index,t-r/2,o)}))}break;case"doughnut":{const x=F.reduce((sum,user)=>sum+user.level,0),m=Math.min(u,p)/3,b=.6*m;let e=-Math.PI/2;const w=d.width/2,D=d.height/2;await Promise.all(F.map(async(user,index)=>{user=user.level/x,user=e+2*Math.PI*user,h.fillStyle=n.pieColors[index%n.pieColors.length]||"#FFFFFF",h.beginPath(),h.moveTo(w+m*Math.cos(e),D+m*Math.sin(e)),h.arc(w,D,m,e,user),h.lineTo(w+b*Math.cos(user),D+b*Math.sin(user)),h.arc(w,D,b,user,e,!0),h.closePath(),h.fill(),e=user}))}break;case"pie":{const y=F.reduce((sum,user)=>sum+user.level,0),S=Math.min(u,p)/3;let e=-Math.PI/2;const v=d.width/2,A=d.height/2;await Promise.all(F.map(async(user,index)=>{user=user.level/y,user=e+2*Math.PI*user,h.fillStyle=n.pieColors[index%n.pieColors.length]||"#FFFFFF",h.beginPath(),h.moveTo(v,A),h.arc(v,A,S,e,user),h.closePath(),h.fill(),e=user}))}break;default:throw new xplogs_1.XpFatal({function:"charts()",message:"Invalid chart type provided"})}if(["doughnut","pie"].includes(options.type)){const E=d.height-20-20*F.length;h.fillStyle="rgba(0,0,0,0.25)",h.fillRect(15,E-5,200,20*F.length+5),h.font="12px Sans Serif",await Promise.all(F.map(async(user,index)=>{var user=user?.name||user.user,e=n.pieColors[index%n.pieColors.length],index=E+20*index;h.fillStyle=e||"#FFFFFF",h.fillRect(20,index,15,15),h.fillStyle=n.textColor,h.fillText(user,40,11.5+index)}))}return{attachment:d.toBuffer("image/png"),description:"Chart",name:"chart.png"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.charts=void 0;const canvas_1=require("@napi-rs/canvas"),path_1=require("path"),leaderboard_1=require("./leaderboard"),cards_1=require("./cards"),xplogs_1=require("./functions/xplogs");exports.charts=charts;
|
package/lib/src/connect.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type ConnectionOptions = {
|
|
|
11
11
|
* @async
|
|
12
12
|
* @param {string} uri
|
|
13
13
|
* @param {ConnectionOptions} options
|
|
14
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/connect
|
|
14
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/connect
|
|
15
15
|
* @returns {Promise<boolean>}
|
|
16
16
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
17
17
|
*/
|
|
@@ -19,8 +19,10 @@ export declare function connect(uri: string, options?: ConnectionOptions): Promi
|
|
|
19
19
|
/**
|
|
20
20
|
* Check database package versions
|
|
21
21
|
* @private
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {string} type - NPM Package Name (lowercase)
|
|
23
|
+
* @param {number} min - Minimum Major Version Number
|
|
24
|
+
* @param {number} max - Maximum Major Version Number (Optional)
|
|
23
25
|
* @returns {Promise<boolean>}
|
|
24
26
|
* @throws {XpFatal} If the package version is not supported
|
|
25
27
|
*/
|
|
26
|
-
export declare function checkPackageVersion(type:
|
|
28
|
+
export declare function checkPackageVersion(type: string, min: number, max?: number): Promise<boolean>;
|
package/lib/src/connect.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @async
|
|
6
6
|
* @param {string} uri
|
|
7
7
|
* @param {ConnectionOptions} options
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/connect
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/connect
|
|
9
9
|
* @returns {Promise<boolean>}
|
|
10
10
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
11
|
-
*/async function connect(uri,options={type:void 0}){var e,{type:o,auto_create:t,auto_purge:
|
|
11
|
+
*/async function connect(uri,options={type:void 0}){var e,{type:o,auto_create:t,auto_purge:n,notify:r,debug:a}=options;if(!uri)throw new xplogs_1.XpFatal({function:"connect()",message:"No URI Provided"});switch(!1===r&&(xp_1.xp.notify=!1),t&&(xp_1.xp.auto_create=!0),n&&(xp_1.xp.auto_purge=!0),a&&(xp_1.xp.debug=!0),o||(options.type="mongodb",xplogs_1.XpLog.warn("connect()","Database type not provided, defaulting to MongoDB")),o){case"mongodb":if(e=(await Promise.resolve().then(()=>__importStar(require("mongodb")))).MongoClient,!await checkPackageVersion("mongodb",4,6))return xplogs_1.XpLog.err("connect()","MongoDB Version 4 to 6 is required");e=await e.connect(uri).catch(error=>{throw new xplogs_1.XpFatal({function:"connect()",message:error.message})}),xp_1.xp.dbType="mongodb",xp_1.xp.database=e||void 0;break;case"sqlite":try{var[i,s]=await Promise.all([Promise.resolve().then(()=>__importStar(require("better-sqlite3"))),checkPackageVersion("better-sqlite3",7,9)]);if(!s)return xplogs_1.XpLog.err("connect()","better-sqlite3 Version 7 to 9 is required");xp_1.xp.database=new i.default(uri),xp_1.xp.dbType="sqlite",xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xps"
|
|
12
12
|
(
|
|
13
13
|
user TEXT NOT NULL,
|
|
14
14
|
guild TEXT NOT NULL,
|
|
15
|
-
name TEXT DEFAULT
|
|
15
|
+
name TEXT DEFAULT user,
|
|
16
16
|
level INTEGER DEFAULT 0,
|
|
17
17
|
xp INTEGER DEFAULT 0
|
|
18
18
|
)`),xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xp-levelroles"
|
|
@@ -24,11 +24,13 @@
|
|
|
24
24
|
* Returns the package manager used
|
|
25
25
|
* @private
|
|
26
26
|
* @returns {Promise<"yarn" | "npm" | "pnpm">}
|
|
27
|
-
*/async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var o=["yarn.lock","pnpm-lock.yaml","pnpm-lock.json","package-lock.json"].filter(lockfile=>e(lockfile));if(1===o.length){if("yarn.lock"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using
|
|
27
|
+
*/async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var o=["yarn.lock","pnpm-lock.yaml","pnpm-lock.json","package-lock.json"].filter(lockfile=>e(lockfile));if(1===o.length){if("yarn.lock"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using YARN"),"yarn";if("pnpm-lock.yaml"===o[0]||"pnpm-lock.json"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using PNPM"),"pnpm"}return xplogs_1.XpLog.debug("getPackageManager()","Using NPM"),"npm"}
|
|
28
28
|
/**
|
|
29
29
|
* Check database package versions
|
|
30
30
|
* @private
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {string} type - NPM Package Name (lowercase)
|
|
32
|
+
* @param {number} min - Minimum Major Version Number
|
|
33
|
+
* @param {number} max - Maximum Major Version Number (Optional)
|
|
32
34
|
* @returns {Promise<boolean>}
|
|
33
35
|
* @throws {XpFatal} If the package version is not supported
|
|
34
|
-
*/async function checkPackageVersion(type
|
|
36
|
+
*/async function checkPackageVersion(type,min,max){try{var e=await Promise.resolve(type+"/package.json").then(s=>__importStar(require(s)));return parseInt(e.version.substring(0,1))>=min&&(!max||parseInt(e.version.substring(0,1))<=max)}catch(e){return xplogs_1.XpLog.info("checkPackageVersion()",`Installing ${type} [V${max||min}] | Please wait...`),(0,child_process_1.execSync)(await getPackageManager()+` add ${type}@${max||min}.x.x`),xplogs_1.XpLog.warn("checkPackageVersion()",`Installed ${type}. Please restart!`),process.exit(1)}}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,o;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(o in mod)"default"!==o&&Object.prototype.hasOwnProperty.call(mod,o)&&__createBinding(e,mod,o);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPackageVersion=exports.connect=void 0;const xplogs_1=require("./functions/xplogs"),child_process_1=require("child_process"),xp_1=require("../xp");exports.connect=connect,exports.checkPackageVersion=checkPackageVersion;
|
package/lib/src/create.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { UserResult } from "./functions/database";
|
|
|
5
5
|
* @param {string} userId
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {string} username
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/create
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/create
|
|
9
9
|
* @returns {Promise<UserResult>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided
|
|
11
11
|
*/
|
package/lib/src/create.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {string} userId
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {string} username
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/create
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/create
|
|
9
9
|
* @returns {Promise<UserResult>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided
|
|
11
11
|
*/async function create(userId,guildId,username){if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});var e;if(username)return await(e=(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db).findOne({collection:"simply-xps",data:{user:userId,guild:guildId}})||e.createOne({collection:"simply-xps",data:{name:username,user:userId,guild:guildId,level:0,xp:0}});throw new xplogs_1.XpFatal({function:"create()",message:"Username was not provided"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.create=void 0;const xplogs_1=require("./functions/xplogs");exports.create=create;
|
|
@@ -7,7 +7,7 @@ import { RankCardOptions } from "../cards";
|
|
|
7
7
|
* @param {string} userId
|
|
8
8
|
* @param {string} _guildId
|
|
9
9
|
* @param {RankCardOptions?} options
|
|
10
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/deprecated/rank
|
|
10
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/deprecated/rank
|
|
11
11
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
12
12
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
13
13
|
*/
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @param {string} userId
|
|
7
7
|
* @param {string} _guildId
|
|
8
8
|
* @param {RankCardOptions?} options
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/deprecated/rank
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/deprecated/rank
|
|
10
10
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
|
-
*/
|
|
13
|
-
async function rank(message,userId,_guildId,options){var e;try{e=await Promise.resolve().then(()=>__importStar(require("discord.js/package.json"))),parseInt(e.version.split(".")[0])<13?xplogs_1.XpLog.warn("rank()","This may not work with Discord.JS v12 or below."):xplogs_1.XpLog.debug("rank()",`Discord.JS v${e.version} detected.`)}catch(e){throw new xplogs_1.XpFatal({function:"rank()",message:"This function requires Discord.JS, as it is only for Discord bots. | Use rankCard() instead."})}if(!message||!message?.guild)throw new xplogs_1.XpFatal({function:"rank()",message:"Invalid Message Provided"});if(!userId)throw new xplogs_1.XpFatal({function:"rank()",message:"No User ID Provided"});if(xplogs_1.XpLog.warn("rank()","DEPRECATED FUNCTION!! Please use rankCard() instead."),e=await message.guild.members.fetch(userId).catch(()=>null))return(0,cards_1.rankCard)({id:message.guild.id,name:message.guild.name},{id:e.id,username:e.user.username,avatarURL:e.user.displayAvatarURL()},options);throw new xplogs_1.XpFatal({function:"rank()",message:"Member not found"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,r;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(r in mod)"default"!==r&&Object.prototype.hasOwnProperty.call(mod,r)&&__createBinding(e,mod,r);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.rank=void 0;const xplogs_1=require("../functions/xplogs"),cards_1=require("../cards");exports.rank=rank;
|
|
12
|
+
*/async function rank(message,userId,_guildId,options){var e;try{e=await Promise.resolve().then(()=>__importStar(require("discord.js/package.json"))),parseInt(e.version.split(".")[0])<13?xplogs_1.XpLog.warn("rank()","This may not work with Discord.JS v12 or below."):xplogs_1.XpLog.debug("rank()",`Discord.JS v${e.version} detected.`)}catch(e){throw new xplogs_1.XpFatal({function:"rank()",message:"This function requires Discord.JS, as it is only for Discord bots. | Use rankCard() instead."})}if(!message||!message?.guild)throw new xplogs_1.XpFatal({function:"rank()",message:"Invalid Message Provided"});if(!userId)throw new xplogs_1.XpFatal({function:"rank()",message:"No User ID Provided"});if(xplogs_1.XpLog.warn("rank()","DEPRECATED FUNCTION!! Please use rankCard() instead."),e=await message.guild.members.fetch(userId).catch(()=>null))return(0,cards_1.rankCard)({id:message.guild.id,name:message.guild.name},{id:e.id,username:e.user.username,avatarURL:e.user.displayAvatarURL()},options);throw new xplogs_1.XpFatal({function:"rank()",message:"Member not found"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,r;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(r in mod)"default"!==r&&Object.prototype.hasOwnProperty.call(mod,r)&&__createBinding(e,mod,r);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.rank=void 0;const xplogs_1=require("../functions/xplogs"),cards_1=require("../cards");exports.rank=rank;
|
package/lib/src/fetch.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { User } from "./leaderboard";
|
|
|
4
4
|
* @async
|
|
5
5
|
* @param {string} userId
|
|
6
6
|
* @param {string} guildId
|
|
7
|
-
* @param {string} username - Username to use if auto_create is enabled
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/fetch
|
|
7
|
+
* @param {string?} username - Username to use if auto_create is enabled
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/fetch
|
|
9
9
|
* @returns {Promise<{name: string | null, user: string, guild: string, level: number, position: number, xp: number}>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided, or if the user data is not found.
|
|
11
11
|
*/
|
|
12
|
-
export declare function fetch(userId: string, guildId: string, username
|
|
12
|
+
export declare function fetch(userId: string, guildId: string, username?: string): Promise<User>;
|
package/lib/src/fetch.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @async
|
|
5
5
|
* @param {string} userId
|
|
6
6
|
* @param {string} guildId
|
|
7
|
-
* @param {string} username - Username to use if auto_create is enabled
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/fetch
|
|
7
|
+
* @param {string?} username - Username to use if auto_create is enabled
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/fetch
|
|
9
9
|
* @returns {Promise<{name: string | null, user: string, guild: string, level: number, position: number, xp: number}>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided, or if the user data is not found.
|
|
11
11
|
*/async function fetch(userId,guildId,username){var e;if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});let t=(e=await(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db.find({collection:"simply-xps",data:{guild:guildId}})).find(u=>u.user===userId);if(!t){if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"fetch()",message:"User data not found"});t=await(await Promise.resolve().then(()=>__importStar(require("./create")))).create(guildId,userId,username)}return guildId=e.sort((a,b)=>b.xp-a.xp).findIndex(u=>u.user===userId)+1,{name:t?.name,user:t.user,guild:t.guild,level:t.level,position:guildId,xp:t.xp}}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetch=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp");exports.fetch=fetch;
|
|
@@ -69,7 +69,7 @@ export declare class db {
|
|
|
69
69
|
/**
|
|
70
70
|
* Gets a collection from the database.
|
|
71
71
|
* @param {collection} collection - The collection to get.
|
|
72
|
-
* @link https://simplyxp.js.org/docs/handlers/database#getCollection Documentation
|
|
72
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#getCollection Documentation
|
|
73
73
|
* @returns {Collection} The collection.
|
|
74
74
|
* @throws {XpFatal} Throws an error if there is no database connection, or database type is invalid.
|
|
75
75
|
*/
|
|
@@ -79,17 +79,26 @@ export declare class db {
|
|
|
79
79
|
*
|
|
80
80
|
* @async
|
|
81
81
|
* @param {UserOptions | LevelRoleOptions} query - The document to create.
|
|
82
|
-
* @link https://simplyxp.js.org/docs/handlers/database#createOne Documentation
|
|
82
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#createOne Documentation
|
|
83
83
|
* @returns {Promise<UserResult | LevelRoleResult>} The created document.
|
|
84
84
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
85
85
|
*/
|
|
86
86
|
static createOne(query: UserOptions | LevelRoleOptions): Promise<UserResult | LevelRoleResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Deletes multiple documents from the database.
|
|
89
|
+
* @async
|
|
90
|
+
* @param {UserOptions | LevelRoleOptions} query - The documents to delete.
|
|
91
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#deleteMany Documentation
|
|
92
|
+
* @returns {Promise<boolean>} `true` if the documents were successfully deleted, otherwise `false`.
|
|
93
|
+
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
94
|
+
*/
|
|
95
|
+
static deleteMany(query: UserOptions | LevelRoleOptions): Promise<boolean>;
|
|
87
96
|
/**
|
|
88
97
|
* Deletes one document from the database.
|
|
89
98
|
*
|
|
90
99
|
* @async
|
|
91
100
|
* @param {UserOptions | LevelRoleOptions} query - The document to delete.
|
|
92
|
-
* @link https://simplyxp.js.org/docs/handlers/database#deleteOne Documentation
|
|
101
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#deleteOne Documentation
|
|
93
102
|
* @returns {Promise<boolean>} `true` if the document was successfully deleted, otherwise `false`.
|
|
94
103
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
95
104
|
*/
|
|
@@ -99,7 +108,7 @@ export declare class db {
|
|
|
99
108
|
*
|
|
100
109
|
* @async
|
|
101
110
|
* @param {UserOptions | LevelRoleOptions} query - The query to search for the document.
|
|
102
|
-
* @link https://simplyxp.js.org/docs/handlers/database#findOne Documentation
|
|
111
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#findOne Documentation
|
|
103
112
|
* @returns {Promise<UserResult | LevelRoleResult>} The found document.
|
|
104
113
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
105
114
|
*/
|
|
@@ -109,7 +118,7 @@ export declare class db {
|
|
|
109
118
|
*
|
|
110
119
|
* @async
|
|
111
120
|
* @param {UserOptions | LevelRoleOptions} query - The query to search for multiple documents.
|
|
112
|
-
* @link https://simplyxp.js.org/docs/handlers/database#find Documentation
|
|
121
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#find Documentation
|
|
113
122
|
* @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
|
|
114
123
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
115
124
|
*/
|
|
@@ -121,7 +130,7 @@ export declare class db {
|
|
|
121
130
|
* @param {UserOptions | LevelRoleOptions} filter - The document to update.
|
|
122
131
|
* @param {UserOptions | LevelRoleOptions} update - The document update data.
|
|
123
132
|
* @param {object} [options] - MongoDB options for updating the document.
|
|
124
|
-
* @link https://simplyxp.js.org/docs/handlers/database#updateOne Documentation
|
|
133
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#updateOne Documentation
|
|
125
134
|
* @returns {Promise<UserResult | LevelRoleResult>} The updated document.
|
|
126
135
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
127
136
|
*/
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* Gets a collection from the database.
|
|
11
11
|
* @param {collection} collection - The collection to get.
|
|
12
|
-
* @link https://simplyxp.js.org/docs/handlers/database#getCollection Documentation
|
|
12
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#getCollection Documentation
|
|
13
13
|
* @returns {Collection} The collection.
|
|
14
14
|
* @throws {XpFatal} Throws an error if there is no database connection, or database type is invalid.
|
|
15
15
|
*/
|
|
@@ -19,16 +19,24 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
19
19
|
*
|
|
20
20
|
* @async
|
|
21
21
|
* @param {UserOptions | LevelRoleOptions} query - The document to create.
|
|
22
|
-
* @link https://simplyxp.js.org/docs/handlers/database#createOne Documentation
|
|
22
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#createOne Documentation
|
|
23
23
|
* @returns {Promise<UserResult | LevelRoleResult>} The created document.
|
|
24
24
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
25
25
|
*/static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":xp_1.xp.database.db().collection(query.collection).insertOne(query.data).catch(error=>handleError(error,"createOne()")),e=db.findOne(query);break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('INSERT INTO "simply-xps" (user, guild, name, xp, level) VALUES (?, ?, ?, ?, ?)').run(query.data.user,query.data.guild,query.data?.name,query.data.xp,query.data.level):xp_1.xp.database.prepare('INSERT INTO "simply-xp-levelroles" (guild, level, role) VALUES (?, ?, ?)').run(query.data.guild,query.data.level,query.data.roles)}return e}
|
|
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 guild = ?')).run(query.data.guild)}return!!e}
|
|
26
34
|
/**
|
|
27
35
|
* Deletes one document from the database.
|
|
28
36
|
*
|
|
29
37
|
* @async
|
|
30
38
|
* @param {UserOptions | LevelRoleOptions} query - The document to delete.
|
|
31
|
-
* @link https://simplyxp.js.org/docs/handlers/database#deleteOne Documentation
|
|
39
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#deleteOne Documentation
|
|
32
40
|
* @returns {Promise<boolean>} `true` if the document was successfully deleted, otherwise `false`.
|
|
33
41
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
34
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):xp_1.xp.database.prepare('DELETE FROM "simply-xp-levelroles" WHERE guild = ? AND level = ?').run(query.data.guild,query.data.level)}return!!e}
|
|
@@ -37,7 +45,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
37
45
|
*
|
|
38
46
|
* @async
|
|
39
47
|
* @param {UserOptions | LevelRoleOptions} query - The query to search for the document.
|
|
40
|
-
* @link https://simplyxp.js.org/docs/handlers/database#findOne Documentation
|
|
48
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#findOne Documentation
|
|
41
49
|
* @returns {Promise<UserResult | LevelRoleResult>} The found document.
|
|
42
50
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
43
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=xp_1.xp.database.db().collection(query.collection).findOne(query.data).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):xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles" WHERE guild = ? AND level = ?').get(query.data.guild,query.data.level)}return e}
|
|
@@ -46,7 +54,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
46
54
|
*
|
|
47
55
|
* @async
|
|
48
56
|
* @param {UserOptions | LevelRoleOptions} query - The query to search for multiple documents.
|
|
49
|
-
* @link https://simplyxp.js.org/docs/handlers/database#find Documentation
|
|
57
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#find Documentation
|
|
50
58
|
* @returns {Promise<UserResult[] | LevelRoleResult[]>} An array of found documents.
|
|
51
59
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
52
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":e=("simply-xps"===query.collection?xp_1.xp.database.prepare('SELECT * FROM "simply-xps" WHERE guild = ?'):xp_1.xp.database.prepare('SELECT * FROM "simply-xp-levelroles" WHERE guild = ?')).all(query.data.guild)}return e}
|
|
@@ -57,7 +65,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
57
65
|
* @param {UserOptions | LevelRoleOptions} filter - The document to update.
|
|
58
66
|
* @param {UserOptions | LevelRoleOptions} update - The document update data.
|
|
59
67
|
* @param {object} [options] - MongoDB options for updating the document.
|
|
60
|
-
* @link https://simplyxp.js.org/docs/handlers/database#updateOne Documentation
|
|
68
|
+
* @link https://simplyxp.js.org/docs/next/handlers/database#updateOne Documentation
|
|
61
69
|
* @returns {Promise<UserResult | LevelRoleResult>} The updated document.
|
|
62
70
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
63
|
-
*/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},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
|
|
71
|
+
*/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},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 = ?, level = ?'+(update.data?.name?", name = ?":"")+" WHERE guild = ? AND user = ?").run(update.data?.name?[update.data.xp,update.data.level,update.data.name,filter.data.guild,filter.data.user]:[update.data.xp,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 role = ? WHERE guild = ? AND level = ?').run(update.data.roles,filter.data.guild,filter.data.level)}}return db.findOne(update)}}exports.db=db;
|
|
@@ -25,7 +25,7 @@ interface NewClientOptions {
|
|
|
25
25
|
*
|
|
26
26
|
* @param {number} value.
|
|
27
27
|
* @param {"xp" | "level"} type - Type to convert from (Default: level).
|
|
28
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/convert
|
|
28
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/utilities/convert
|
|
29
29
|
* @returns {number} - The converted value. (XP to level or level to XP)
|
|
30
30
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
31
31
|
*/
|
|
@@ -33,7 +33,7 @@ export declare function convertFrom(value: number, type?: "xp" | "level"): numbe
|
|
|
33
33
|
/**
|
|
34
34
|
* Updates the options of the XP client.
|
|
35
35
|
* @param {NewClientOptions} clientOptions - The new options to update.
|
|
36
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/updateOptions
|
|
36
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/utilities/updateOptions
|
|
37
37
|
* @returns {void} - Nothing.
|
|
38
38
|
* @throws {XpFatal} If an invalid option is provided.
|
|
39
39
|
*/
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @param {number} value.
|
|
6
6
|
* @param {"xp" | "level"} type - Type to convert from (Default: level).
|
|
7
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/convert
|
|
7
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/utilities/convert
|
|
8
8
|
* @returns {number} - The converted value. (XP to level or level to XP)
|
|
9
9
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
10
10
|
*/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(value/.1,2);if("xp"===type)return Math.floor(.1*Math.sqrt(value));throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Invalid type provided"})}
|
|
11
11
|
/**
|
|
12
12
|
* Updates the options of the XP client.
|
|
13
13
|
* @param {NewClientOptions} clientOptions - The new options to update.
|
|
14
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/updateOptions
|
|
14
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/utilities/updateOptions
|
|
15
15
|
* @returns {void} - Nothing.
|
|
16
16
|
* @throws {XpFatal} If an invalid option is provided.
|
|
17
|
-
*/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(xp_1.xp.auto_create=clientOptions.auto_create,xp_1.xp.auto_purge=clientOptions.auto_purge,xp_1.xp.notify=clientOptions.notify,xp_1.xp.debug=clientOptions.debug,clientOptions.dbOptions&&"object"==typeof clientOptions.dbOptions&&clientOptions.dbOptions.type&&clientOptions.dbOptions.database){var{type:clientOptions,database:t}=clientOptions.dbOptions;if(!(clientOptions&&"mongodb"===clientOptions||"sqlite"===clientOptions))throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid database type provided"});xp_1.xp.dbType=clientOptions,t
|
|
17
|
+
*/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(xp_1.xp.auto_create=clientOptions.auto_create,xp_1.xp.auto_purge=clientOptions.auto_purge,xp_1.xp.notify=clientOptions.notify,xp_1.xp.debug=clientOptions.debug,clientOptions.dbOptions&&"object"==typeof clientOptions.dbOptions&&clientOptions.dbOptions.type&&clientOptions.dbOptions.database){var{type:clientOptions,database:t}=clientOptions.dbOptions;if(!(clientOptions&&"mongodb"===clientOptions||"sqlite"===clientOptions))throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid database type provided"});if(xp_1.xp.dbType=clientOptions,t){xp_1.xp.database=t;const e="mongodb"===xp_1.xp.dbType?{name:"MongoDB",type:"mongodb",min:4,max:6}:{name:"Better-SQLite3",type:"better-sqlite3",min:7,max:9};(0,connect_1.checkPackageVersion)(e.type,e.min,e.max).then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:`${e.name} V${e.min} up to V${e.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(t){throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid SQLite connection"})}}})}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateOptions=exports.convertFrom=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp"),connect_1=require("../connect");exports.convertFrom=convertFrom,exports.updateOptions=updateOptions;
|
package/lib/src/leaderboard.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface User {
|
|
|
20
20
|
* @async
|
|
21
21
|
* @param {string} guildId - Guild ID
|
|
22
22
|
* @param {number} limit - Limit of users to return
|
|
23
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/leaderboard
|
|
23
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/leaderboard
|
|
24
24
|
* @returns {Promise<User[]>} Array of all users in the leaderboard
|
|
25
25
|
* @throws {XpFatal} If guild ID is not provided or limit is less than 1
|
|
26
26
|
*/
|
package/lib/src/leaderboard.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @async
|
|
5
5
|
* @param {string} guildId - Guild ID
|
|
6
6
|
* @param {number} limit - Limit of users to return
|
|
7
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/leaderboard
|
|
7
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/leaderboard
|
|
8
8
|
* @returns {Promise<User[]>} Array of all users in the leaderboard
|
|
9
9
|
* @throws {XpFatal} If guild ID is not provided or limit is less than 1
|
|
10
|
-
*/async function leaderboard(guildId,limit){if(!guildId)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Guild ID was not provided"});if(limit
|
|
10
|
+
*/async function leaderboard(guildId,limit){if(!guildId)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Guild ID was not provided"});if(!limit||1<=limit)return guildId=(await database_1.db.find({collection:"simply-xps",data:{guild:guildId}})).sort((a,b)=>b.xp-a.xp),await Promise.all(guildId.map(async(user,index)=>(user.position=index+1,user))),guildId.slice(0,limit);throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Limit must be a number greater than 0"})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.leaderboard=void 0;const xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database");exports.leaderboard=leaderboard;
|
package/lib/src/migrate.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class migrate {
|
|
|
9
9
|
* Effortlessly migrate from discord-xp to simply-xp.
|
|
10
10
|
* @async
|
|
11
11
|
* @param {boolean} deleteOld - Delete old data after migration
|
|
12
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/migrate
|
|
12
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratediscord_xp
|
|
13
13
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
14
14
|
* @throws {XpLog.err} - If migration fails.
|
|
15
15
|
*/
|
|
@@ -19,7 +19,7 @@ export declare class migrate {
|
|
|
19
19
|
* @async
|
|
20
20
|
* @param {"mongodb"|"sqlite"} dbType
|
|
21
21
|
* @param {Database | MongoClient} connection
|
|
22
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/migrate
|
|
22
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratefromdb
|
|
23
23
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
24
24
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
25
25
|
*/
|
package/lib/src/migrate.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Effortlessly migrate from discord-xp to simply-xp.
|
|
4
4
|
* @async
|
|
5
5
|
* @param {boolean} deleteOld - Delete old data after migration
|
|
6
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/migrate
|
|
6
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratediscord_xp
|
|
7
7
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
8
8
|
* @throws {XpLog.err} - If migration fails.
|
|
9
9
|
*/
|
|
10
|
-
static async discord_xp(deleteOld=!1){var e=await database_1.db.getCollection("levels").find().toArray();xplogs_1.XpLog.debug("migrate.discord_xp()",`FOUND ${e.length} DOCUMENTS`);try{for(const
|
|
10
|
+
static async discord_xp(deleteOld=!1){var e=await database_1.db.getCollection("levels").find().toArray();xplogs_1.XpLog.debug("migrate.discord_xp()",`FOUND ${e.length} DOCUMENTS`);try{for(const a of e)await database_1.db.findOne({collection:"simply-xps",data:{guild:a.guildID,user:a.userID}})||(await database_1.db.createOne({collection:"simply-xps",data:{guild:a.guildID,user:a.userID,xp:a.xp,level:(0,xp_1.convertFrom)(a.xp,"xp")}}),deleteOld&&await database_1.db.getCollection("levels").deleteOne({userID:a.userID,guildID:a.guildID}));return!0}catch(e){return xplogs_1.XpLog.err("migrate.discord_xp()",e),!1}}
|
|
11
11
|
/**
|
|
12
12
|
* Effortlessly migrate from MongoDB to SQLite. (or vice versa)
|
|
13
13
|
* @async
|
|
14
14
|
* @param {"mongodb"|"sqlite"} dbType
|
|
15
15
|
* @param {Database | MongoClient} connection
|
|
16
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/migrate
|
|
16
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/migrate#migratefromdb
|
|
17
17
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
18
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"))return xplogs_1.XpLog.err("migrate.fromDB()","MongoDB V4
|
|
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 database_1.db.findOne({collection:"simply-xps",data:{guild:user.guild,user:user.user}})?database_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}}):database_1.db.createOne({collection:"simply-xps",data:{guild:user.guild,user:user.user,xp:user.xp,level:user.level}}))),!0}}exports.migrate=migrate;
|
package/lib/src/reset.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {string} guildId
|
|
6
6
|
* @param {boolean?} erase - Erase user entry from the database
|
|
7
7
|
* @param {string?} username - Username to use if auto_create is enabled
|
|
8
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/reset
|
|
8
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/reset
|
|
9
9
|
* @returns {Promise<boolean>}
|
|
10
10
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
11
11
|
*/
|
package/lib/src/reset.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {boolean?} erase - Erase user entry from the database
|
|
8
8
|
* @param {string?} username - Username to use if auto_create is enabled
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/reset
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/reset
|
|
10
10
|
* @returns {Promise<boolean>}
|
|
11
11
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
12
12
|
*/async function reset(userId,guildId,erase=!1,username){var e;if(userId&&guildId)return e={guild:guildId,user:userId},await database_1.db.findOne({collection:"simply-xps",data:e})?(erase?await database_1.db.deleteOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}):await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{...e,level:0,xp:0}}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}),!0):xp_1.xp.auto_create&&!erase&&username?(await database_1.db.createOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error.stack})}),!0):xplogs_1.XpLog.info("reset()","User was not found, we did not know what to do without a username.");throw new xplogs_1.XpFatal({function:"reset()",message:"Invalid parameters provided"})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.reset=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp"),database_1=require("./functions/database");exports.reset=reset;
|
package/lib/src/roleSetup.d.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @property {string[] | string} roles - The role(s) to add
|
|
6
6
|
*/
|
|
7
7
|
export interface RoleSetupObject {
|
|
8
|
-
guild?: string;
|
|
9
8
|
level: number;
|
|
10
9
|
roles: string[] | string;
|
|
11
10
|
}
|
|
@@ -19,7 +18,7 @@ export declare class roleSetup {
|
|
|
19
18
|
* @async
|
|
20
19
|
* @param {string} guildId - The guild ID
|
|
21
20
|
* @param {RoleSetupObject} options - Level/role options
|
|
22
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
21
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupadd
|
|
23
22
|
* @returns {Promise<boolean>} - True if successful
|
|
24
23
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
25
24
|
*/
|
|
@@ -29,7 +28,7 @@ export declare class roleSetup {
|
|
|
29
28
|
* @async
|
|
30
29
|
* @param {string} guildId - The guild ID
|
|
31
30
|
* @param {number} levelNumber - The level number
|
|
32
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
31
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupfind
|
|
33
32
|
* @returns {Promise<RoleSetupObject>} - The level role object
|
|
34
33
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
35
34
|
*/
|
|
@@ -39,7 +38,7 @@ export declare class roleSetup {
|
|
|
39
38
|
* @async
|
|
40
39
|
* @param {string} guildId - The guild ID
|
|
41
40
|
* @param {number} levelNumber - The level number
|
|
42
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
41
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupremove
|
|
43
42
|
* @returns {Promise<boolean>} - True if successful
|
|
44
43
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
45
44
|
*/
|
package/lib/src/roleSetup.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @async
|
|
5
5
|
* @param {string} guildId - The guild ID
|
|
6
6
|
* @param {RoleSetupObject} options - Level/role options
|
|
7
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
7
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupadd
|
|
8
8
|
* @returns {Promise<boolean>} - True if successful
|
|
9
9
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ static async add(guildId,options){if(!guildId)throw new xplogs_1.XpFatal({functi
|
|
|
14
14
|
* @async
|
|
15
15
|
* @param {string} guildId - The guild ID
|
|
16
16
|
* @param {number} levelNumber - The level number
|
|
17
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
17
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupfind
|
|
18
18
|
* @returns {Promise<RoleSetupObject>} - The level role object
|
|
19
19
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
20
20
|
*/static async find(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.find()",message:"Level Number was not provided"});return xp_1.db.findOne({collection:"simply-xp-levelroles",data:{guild:guildId,level:levelNumber,timestamp:(new Date).toISOString()}})}
|
|
@@ -23,7 +23,7 @@ static async add(guildId,options){if(!guildId)throw new xplogs_1.XpFatal({functi
|
|
|
23
23
|
* @async
|
|
24
24
|
* @param {string} guildId - The guild ID
|
|
25
25
|
* @param {number} levelNumber - The level number
|
|
26
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/roleSetup
|
|
26
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/classes/roleSetup#roleSetupremove
|
|
27
27
|
* @returns {Promise<boolean>} - True if successful
|
|
28
28
|
* @throws {XpFatal} If an invalid type is provided or value is not provided.
|
|
29
29
|
*/static async remove(guildId,levelNumber){if(!guildId)throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Guild ID was not provided"});if(isNaN(levelNumber))throw new xplogs_1.XpFatal({function:"roleSetup.remove()",message:"Level Number was not provided"});return xp_1.db.deleteOne({collection:"simply-xp-levelroles",data:{guild:guildId,level:levelNumber,timestamp:(new Date).toISOString()}})}}exports.roleSetup=roleSetup;
|
package/lib/src/set.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { UserResult } from "./functions/database";
|
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {number} level
|
|
8
8
|
* @param {string} username - Username to use if auto_create is enabled
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/setlevel
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/setlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
12
|
*/
|
|
@@ -25,7 +25,7 @@ interface XPResult extends UserResult {
|
|
|
25
25
|
* @param {string} guildId
|
|
26
26
|
* @param {number} xpData
|
|
27
27
|
* @param {string} username - Username to use if auto_create is enabled
|
|
28
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/setxp
|
|
28
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/setxp
|
|
29
29
|
* @returns {Promise<XPResult>} - Object of user data on success
|
|
30
30
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
31
31
|
*/
|
package/lib/src/set.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {string} guildId
|
|
7
7
|
* @param {number} level
|
|
8
8
|
* @param {string} username - Username to use if auto_create is enabled
|
|
9
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/setlevel
|
|
9
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/setlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
12
|
*/async function setLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"setLevel()",message:"Level was not provided"});if(await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}}))return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:level,xp:(0,utilities_1.convertFrom)(level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"setLevel()",message:"User does not exist"})}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @param {string} guildId
|
|
18
18
|
* @param {number} xpData
|
|
19
19
|
* @param {string} username - Username to use if auto_create is enabled
|
|
20
|
-
* @link `Documentation:` https://simplyxp.js.org/docs/setxp
|
|
20
|
+
* @link `Documentation:` https://simplyxp.js.org/docs/next/functions/setxp
|
|
21
21
|
* @returns {Promise<XPResult>} - Object of user data on success
|
|
22
22
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
23
23
|
*/async function setXP(userId,guildId,xpData,username){if(!userId)throw new xplogs_1.XpFatal({function:"setXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setXP()",message:"Guild ID was not provided"});if(isNaN(xpData))throw new xplogs_1.XpFatal({function:"setXP()",message:"XP was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let s;if(e)s=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"setXP()",message:"User does not exist"});s=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}})}return{...s,hasLevelledUp:s.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.setXP=exports.setLevel=void 0;const xplogs_1=require("./functions/xplogs"),utilities_1=require("./functions/utilities"),database_1=require("./functions/database"),xp_1=require("../xp");exports.setLevel=setLevel,exports.setXP=setXP;
|
package/lib/xp.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ export interface XPClient {
|
|
|
11
11
|
export { addLevel, addXP } from "./src/add";
|
|
12
12
|
export { db } from "./src/functions/database";
|
|
13
13
|
export { charts } from "./src/charts";
|
|
14
|
+
export { compareCard, leaderboardCard, rankCard } from "./src/cards";
|
|
14
15
|
export { connect } from "./src/connect";
|
|
15
16
|
export { convertFrom, updateOptions } from "./src/functions/utilities";
|
|
16
17
|
export { create } from "./src/create";
|
|
17
18
|
export { fetch } from "./src/fetch";
|
|
18
19
|
export { leaderboard } from "./src/leaderboard";
|
|
19
20
|
export { migrate } from "./src/migrate";
|
|
20
|
-
export { rankCard, leaderboardCard } from "./src/cards";
|
|
21
21
|
export { reset } from "./src/reset";
|
|
22
22
|
export { roleSetup } from "./src/roleSetup";
|
|
23
23
|
export { setLevel, setXP } from "./src/set";
|
package/lib/xp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rank = exports.xp = exports.setXP = exports.setLevel = exports.roleSetup = exports.reset = exports.
|
|
3
|
+
exports.rank = exports.xp = exports.setXP = exports.setLevel = exports.roleSetup = exports.reset = exports.migrate = exports.leaderboard = exports.fetch = exports.create = exports.updateOptions = exports.convertFrom = exports.connect = exports.rankCard = exports.leaderboardCard = exports.compareCard = exports.charts = exports.db = exports.addXP = exports.addLevel = void 0;
|
|
4
4
|
// EXPORTS
|
|
5
5
|
var add_1 = require("./src/add");
|
|
6
6
|
Object.defineProperty(exports, "addLevel", { enumerable: true, get: function () { return add_1.addLevel; } });
|
|
@@ -9,6 +9,10 @@ var database_1 = require("./src/functions/database");
|
|
|
9
9
|
Object.defineProperty(exports, "db", { enumerable: true, get: function () { return database_1.db; } });
|
|
10
10
|
var charts_1 = require("./src/charts");
|
|
11
11
|
Object.defineProperty(exports, "charts", { enumerable: true, get: function () { return charts_1.charts; } });
|
|
12
|
+
var cards_1 = require("./src/cards");
|
|
13
|
+
Object.defineProperty(exports, "compareCard", { enumerable: true, get: function () { return cards_1.compareCard; } });
|
|
14
|
+
Object.defineProperty(exports, "leaderboardCard", { enumerable: true, get: function () { return cards_1.leaderboardCard; } });
|
|
15
|
+
Object.defineProperty(exports, "rankCard", { enumerable: true, get: function () { return cards_1.rankCard; } });
|
|
12
16
|
var connect_1 = require("./src/connect");
|
|
13
17
|
Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return connect_1.connect; } });
|
|
14
18
|
var utilities_1 = require("./src/functions/utilities");
|
|
@@ -22,9 +26,6 @@ var leaderboard_1 = require("./src/leaderboard");
|
|
|
22
26
|
Object.defineProperty(exports, "leaderboard", { enumerable: true, get: function () { return leaderboard_1.leaderboard; } });
|
|
23
27
|
var migrate_1 = require("./src/migrate");
|
|
24
28
|
Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return migrate_1.migrate; } });
|
|
25
|
-
var cards_1 = require("./src/cards");
|
|
26
|
-
Object.defineProperty(exports, "rankCard", { enumerable: true, get: function () { return cards_1.rankCard; } });
|
|
27
|
-
Object.defineProperty(exports, "leaderboardCard", { enumerable: true, get: function () { return cards_1.leaderboardCard; } });
|
|
28
29
|
var reset_1 = require("./src/reset");
|
|
29
30
|
Object.defineProperty(exports, "reset", { enumerable: true, get: function () { return reset_1.reset; } });
|
|
30
31
|
var roleSetup_1 = require("./src/roleSetup");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simply-xp",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.5",
|
|
4
4
|
"description": "The easiest way to implement xp system",
|
|
5
5
|
"main": "lib/xp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"author": "Abadima",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"amaribot",
|
|
17
|
+
"canvacord",
|
|
17
18
|
"charts",
|
|
19
|
+
"compare",
|
|
20
|
+
"compete",
|
|
18
21
|
"discord",
|
|
19
22
|
"discord.js",
|
|
20
23
|
"discord-xp",
|
|
@@ -22,14 +25,15 @@
|
|
|
22
25
|
"fun",
|
|
23
26
|
"guilded",
|
|
24
27
|
"leaderboard",
|
|
25
|
-
"level
|
|
26
|
-
"
|
|
28
|
+
"level",
|
|
29
|
+
"leveling",
|
|
27
30
|
"mee6",
|
|
28
31
|
"mongodb",
|
|
29
32
|
"package",
|
|
30
33
|
"simply",
|
|
31
34
|
"simply-djs",
|
|
32
35
|
"simplydjs",
|
|
36
|
+
"slack",
|
|
33
37
|
"sqlite",
|
|
34
38
|
"system",
|
|
35
39
|
"xp"
|
|
@@ -37,33 +41,32 @@
|
|
|
37
41
|
"license": "Apache-2.0",
|
|
38
42
|
"repository": {
|
|
39
43
|
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/
|
|
44
|
+
"url": "git+https://github.com/Abadima/simply-xp.git"
|
|
41
45
|
},
|
|
42
46
|
"dependencies": {
|
|
43
47
|
"@napi-rs/canvas": "^0.1.44"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"@types/better-sqlite3": "^7.6.
|
|
47
|
-
"@types/node": "^20.
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
49
|
-
"@typescript-eslint/parser": "^6.
|
|
50
|
-
"better-sqlite3": "
|
|
50
|
+
"@types/better-sqlite3": "^7.6.5",
|
|
51
|
+
"@types/node": "^20.8.6",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
53
|
+
"@typescript-eslint/parser": "^6.7.5",
|
|
54
|
+
"better-sqlite3": "^9.0.0",
|
|
51
55
|
"discord.js": "^14.13.0",
|
|
52
|
-
"eslint": "^8.
|
|
56
|
+
"eslint": "^8.51.0",
|
|
53
57
|
"jsdoc-to-markdown": "^8.0.0",
|
|
54
|
-
"mongodb": "^
|
|
55
|
-
"typescript": "^5.
|
|
58
|
+
"mongodb": "^6.1.0",
|
|
59
|
+
"typescript": "^5.2.2",
|
|
56
60
|
"uglify-js": "^3.17.4"
|
|
57
61
|
},
|
|
58
62
|
"engines": {
|
|
59
63
|
"node": ">=15.5.0"
|
|
60
64
|
},
|
|
61
65
|
"bugs": {
|
|
62
|
-
"url": "https://github.com/
|
|
66
|
+
"url": "https://github.com/Abadima/simply-xp/issues"
|
|
63
67
|
},
|
|
64
68
|
"homepage": "https://simplyxp.js.org",
|
|
65
69
|
"directories": {
|
|
66
|
-
"doc": "Mini_Docs",
|
|
67
70
|
"lib": "lib"
|
|
68
71
|
}
|
|
69
72
|
}
|
|
Binary file
|