simply-xp 1.3.5-beta-6 → 1.3.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 +56 -56
- package/index.d.ts +1 -0
- package/package.json +54 -50
- package/simplyxp.js +33 -31
- package/src/addLevel.js +66 -66
- package/src/addXP.js +104 -103
- package/src/charts.js +92 -92
- package/src/connect.js +21 -22
- package/src/create.js +28 -28
- package/src/fetch.js +74 -74
- package/src/leaderboard.js +51 -52
- package/src/lvlRole.js +53 -53
- package/src/models/level.js +10 -10
- package/src/models/lvlrole.js +8 -8
- package/src/rank.js +295 -294
- package/src/reset.js +22 -22
- package/src/roleSetup.js +121 -121
- package/src/setLevel.js +42 -70
- package/src/setXP.js +23 -51
- package/.github/CODE_OF_CONDUCT.md +0 -128
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/SECURITY.md +0 -25
- package/.github/pull_request_template.md +0 -8
- package/.github/workflows/codeql-analysis.yml +0 -71
- package/.idea/discord.xml +0 -7
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/simply-xp.iml +0 -9
- package/.idea/workspace.xml +0 -55
package/src/models/level.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const mongoose = require(
|
|
2
|
-
|
|
3
|
-
const Levelz = new mongoose.Schema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
module.exports = mongoose.model(
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const Levelz = new mongoose.Schema({
|
|
4
|
+
user: {type: String, unique: true},
|
|
5
|
+
guild: {type: String},
|
|
6
|
+
xp: {type: Number, default: 0},
|
|
7
|
+
level: {type: Number, default: 0}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
module.exports = mongoose.model("Simply-XP", Levelz);
|
package/src/models/lvlrole.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const mongoose = require(
|
|
2
|
-
|
|
3
|
-
const rol = new mongoose.Schema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
module.exports = mongoose.model(
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const rol = new mongoose.Schema({
|
|
4
|
+
gid: {type: String},
|
|
5
|
+
lvlrole: {type: Array}
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
module.exports = mongoose.model("Simply-XP-LevelRole", rol);
|
package/src/rank.js
CHANGED
|
@@ -1,294 +1,295 @@
|
|
|
1
|
-
const levels = require(
|
|
2
|
-
const {join} = require(
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {Discord.Message} message
|
|
6
|
-
* @param {string} userID
|
|
7
|
-
* @param {string} guildID
|
|
8
|
-
* @param {import(
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
async function rank(message, userID, guildID, options = []) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
module.exports = rank
|
|
1
|
+
const levels = require("../src/models/level.js");
|
|
2
|
+
const {join} = require("path");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {Discord.Message} message
|
|
6
|
+
* @param {string} userID
|
|
7
|
+
* @param {string} guildID
|
|
8
|
+
* @param {import("../index").rankOptions} options
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
async function rank(message, userID, guildID, options = []) {
|
|
12
|
+
if (!userID) throw new Error("[XP] User ID was not provided.");
|
|
13
|
+
|
|
14
|
+
if (!guildID) throw new Error("[XP] Guild ID was not provided.");
|
|
15
|
+
|
|
16
|
+
const user = await levels.findOne({
|
|
17
|
+
user: userID,
|
|
18
|
+
guild: guildID
|
|
19
|
+
});
|
|
20
|
+
if (!user) throw new Error("[XP] NO_DATA | User has no XP data.");
|
|
21
|
+
|
|
22
|
+
const leaderboard = await levels
|
|
23
|
+
.find({
|
|
24
|
+
guild: guildID
|
|
25
|
+
})
|
|
26
|
+
.sort([["xp", "descending"]])
|
|
27
|
+
.exec();
|
|
28
|
+
|
|
29
|
+
user.position = leaderboard.findIndex((i) => i.user === userID) + 1;
|
|
30
|
+
|
|
31
|
+
let targetxp = user.level + 1;
|
|
32
|
+
|
|
33
|
+
let target = targetxp * targetxp * 100;
|
|
34
|
+
|
|
35
|
+
return rankCard(message, {
|
|
36
|
+
level: user.level,
|
|
37
|
+
currentXP: user.xp,
|
|
38
|
+
neededXP: target,
|
|
39
|
+
rank: user.position,
|
|
40
|
+
background: options.background,
|
|
41
|
+
color: options.color,
|
|
42
|
+
lvlbar: options.lvlbar,
|
|
43
|
+
lvlbarBg: options.lvlbarBg,
|
|
44
|
+
member: message.guild.members.cache.get(userID)?.user
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async function rankCard(message, options = []) {
|
|
48
|
+
try {
|
|
49
|
+
const Canvas = require("@napi-rs/canvas");
|
|
50
|
+
Canvas.GlobalFonts.registerFromPath(
|
|
51
|
+
join(__dirname, "Fonts", "Baloo-Regular.ttf"),
|
|
52
|
+
"Sans Serif"
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const member = options.member;
|
|
56
|
+
|
|
57
|
+
const canvas = Canvas.createCanvas(1080, 400),
|
|
58
|
+
ctx = canvas.getContext("2d");
|
|
59
|
+
|
|
60
|
+
const name = member.tag;
|
|
61
|
+
const noSymbols = (string) => string.replace(/[\u007f-\uffff]/g, "");
|
|
62
|
+
|
|
63
|
+
let fsiz = "45px";
|
|
64
|
+
if (message.guild.name.length >= 23) {
|
|
65
|
+
fsiz = "38px";
|
|
66
|
+
}
|
|
67
|
+
if (message.guild.name.length >= 40) {
|
|
68
|
+
fsiz = "28px";
|
|
69
|
+
}
|
|
70
|
+
if (message.guild.name.length >= 63) {
|
|
71
|
+
fsiz = "22px";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let BackgroundRadius = "20",
|
|
75
|
+
BackGroundImg =
|
|
76
|
+
options.background ||
|
|
77
|
+
"https://i.ibb.co/QQvMqf7/gradient.jpg",
|
|
78
|
+
AttachmentName = "rank.png",
|
|
79
|
+
AttachmentDesc = "Rank Card",
|
|
80
|
+
Username = noSymbols(name),
|
|
81
|
+
AvatarRoundRadius = "50",
|
|
82
|
+
DrawLayerColor = "#000000",
|
|
83
|
+
DrawLayerOpacity = 0.4,
|
|
84
|
+
BoxColor = options.color || "#096DD1",
|
|
85
|
+
LevelBarFill = options.lvlbar || "#ffffff",
|
|
86
|
+
LevelBarBackground = options.lvlbarBg || "#ffffff",
|
|
87
|
+
Rank = options.rank,
|
|
88
|
+
TextEXP = shortener(options.currentXP) + " XP",
|
|
89
|
+
LvlText = `Level ${shortener(options.level)}`,
|
|
90
|
+
BarRadius = "20",
|
|
91
|
+
TextXpNeded = "{current}/{needed}",
|
|
92
|
+
CurrentXP = options.currentXP,
|
|
93
|
+
NeededXP = options.neededXP;
|
|
94
|
+
|
|
95
|
+
ctx.beginPath();
|
|
96
|
+
ctx.moveTo(Number(BackgroundRadius), 0);
|
|
97
|
+
ctx.lineTo(1080 - Number(BackgroundRadius), 0);
|
|
98
|
+
ctx.quadraticCurveTo(1080, 0, 1080, Number(BackgroundRadius));
|
|
99
|
+
ctx.lineTo(1080, 400 - Number(BackgroundRadius));
|
|
100
|
+
ctx.quadraticCurveTo(
|
|
101
|
+
1080,
|
|
102
|
+
400,
|
|
103
|
+
1080 - Number(BackgroundRadius),
|
|
104
|
+
400
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
ctx.lineTo(Number(BackgroundRadius), 400);
|
|
108
|
+
ctx.quadraticCurveTo(0, 400, 0, 400 - Number(BackgroundRadius));
|
|
109
|
+
ctx.lineTo(0, Number(BackgroundRadius));
|
|
110
|
+
ctx.quadraticCurveTo(0, 0, Number(BackgroundRadius), 0);
|
|
111
|
+
ctx.closePath();
|
|
112
|
+
ctx.clip();
|
|
113
|
+
ctx.fillStyle = "#000000";
|
|
114
|
+
ctx.fillRect(0, 0, 1080, 400);
|
|
115
|
+
let background = await Canvas.loadImage(BackGroundImg);
|
|
116
|
+
ctx.globalAlpha = 0.7;
|
|
117
|
+
ctx.drawImage(background, 0, 0, 1080, 400);
|
|
118
|
+
ctx.restore();
|
|
119
|
+
|
|
120
|
+
ctx.fillStyle = DrawLayerColor;
|
|
121
|
+
ctx.globalAlpha = DrawLayerOpacity;
|
|
122
|
+
ctx.fillRect(40, 0, 240, canvas.height);
|
|
123
|
+
ctx.globalAlpha = 1;
|
|
124
|
+
|
|
125
|
+
let avatar = await Canvas.loadImage(member.displayAvatarURL());
|
|
126
|
+
ctx.save();
|
|
127
|
+
RoundedBox(ctx, 70, 30, 180, 180, Number(AvatarRoundRadius));
|
|
128
|
+
ctx.strokeStyle = BoxColor;
|
|
129
|
+
ctx.lineWidth = 15;
|
|
130
|
+
ctx.stroke();
|
|
131
|
+
ctx.clip();
|
|
132
|
+
ctx.drawImage(avatar, 70, 30, 180, 180);
|
|
133
|
+
ctx.restore();
|
|
134
|
+
|
|
135
|
+
ctx.save();
|
|
136
|
+
RoundedBox(ctx, 70, 240 + 50 + 30, 180, 50, 20);
|
|
137
|
+
ctx.strokeStyle = "#BFC85A22";
|
|
138
|
+
ctx.stroke();
|
|
139
|
+
ctx.clip();
|
|
140
|
+
ctx.fillStyle = BoxColor;
|
|
141
|
+
ctx.globalAlpha = 1;
|
|
142
|
+
ctx.fillRect(70, 320, 180, 50);
|
|
143
|
+
ctx.globalAlpha = 1;
|
|
144
|
+
ctx.fillStyle = "#ffffff";
|
|
145
|
+
ctx.font = "32px \"Sans Serif\"";
|
|
146
|
+
ctx.textAlign = "center";
|
|
147
|
+
ctx.fillText(TextEXP, 160, 358);
|
|
148
|
+
ctx.restore();
|
|
149
|
+
|
|
150
|
+
ctx.save();
|
|
151
|
+
RoundedBox(ctx, 70, 240, 180, 50, 20);
|
|
152
|
+
ctx.strokeStyle = "#BFC85A22";
|
|
153
|
+
ctx.stroke();
|
|
154
|
+
ctx.clip();
|
|
155
|
+
ctx.fillStyle = BoxColor;
|
|
156
|
+
ctx.globalAlpha = 1;
|
|
157
|
+
ctx.fillRect(70, 240, 180, 50, 50);
|
|
158
|
+
ctx.globalAlpha = 1;
|
|
159
|
+
ctx.fillStyle = "#ffffff";
|
|
160
|
+
ctx.font = "32px \"Sans Serif\"";
|
|
161
|
+
ctx.textAlign = "center";
|
|
162
|
+
ctx.fillText(LvlText, 70 + 180 / 2, 278);
|
|
163
|
+
ctx.restore();
|
|
164
|
+
|
|
165
|
+
ctx.save();
|
|
166
|
+
ctx.textAlign = "left";
|
|
167
|
+
ctx.fillStyle = "#ffffff";
|
|
168
|
+
ctx.shadowColor = "#000000";
|
|
169
|
+
ctx.shadowBlur = 15;
|
|
170
|
+
ctx.shadowOffsetX = 1;
|
|
171
|
+
ctx.shadowOffsetY = 1;
|
|
172
|
+
ctx.font = "39px \"Sans Serif\"";
|
|
173
|
+
ctx.fillText(Username, 390, 80);
|
|
174
|
+
ctx.restore();
|
|
175
|
+
|
|
176
|
+
ctx.save();
|
|
177
|
+
ctx.textAlign = "right";
|
|
178
|
+
ctx.fillStyle = "#ffffff";
|
|
179
|
+
ctx.shadowColor = "#000000";
|
|
180
|
+
ctx.shadowBlur = 15;
|
|
181
|
+
ctx.shadowOffsetX = 1;
|
|
182
|
+
ctx.shadowOffsetY = 1;
|
|
183
|
+
ctx.font = "55px \"Sans Serif\"";
|
|
184
|
+
ctx.fillText("#" + Rank, canvas.width - 55, 80);
|
|
185
|
+
ctx.restore();
|
|
186
|
+
|
|
187
|
+
ctx.save();
|
|
188
|
+
RoundedBox(ctx, 390, 305, 660, 70, Number(20));
|
|
189
|
+
ctx.strokeStyle = "#BFC85A22";
|
|
190
|
+
ctx.stroke();
|
|
191
|
+
ctx.clip();
|
|
192
|
+
ctx.fillStyle = "#ffffff";
|
|
193
|
+
ctx.font = `${fsiz} "Sans Serif"`;
|
|
194
|
+
ctx.textAlign = "center";
|
|
195
|
+
ctx.fillText(message.guild.name, 720, 355);
|
|
196
|
+
ctx.globalAlpha = 0.2;
|
|
197
|
+
ctx.fillRect(390, 305, 660, 70);
|
|
198
|
+
ctx.restore();
|
|
199
|
+
|
|
200
|
+
ctx.save();
|
|
201
|
+
RoundedBox(ctx, 390, 145, 660, 50, Number(BarRadius));
|
|
202
|
+
ctx.strokeStyle = "#BFC85A22";
|
|
203
|
+
ctx.stroke();
|
|
204
|
+
ctx.clip();
|
|
205
|
+
ctx.fillStyle = LevelBarBackground;
|
|
206
|
+
ctx.globalAlpha = 0.2;
|
|
207
|
+
ctx.fillRect(390, 145, 660, 50, 50);
|
|
208
|
+
ctx.restore();
|
|
209
|
+
|
|
210
|
+
const percent = (100 * CurrentXP) / NeededXP;
|
|
211
|
+
const progress = (percent * 660) / 100;
|
|
212
|
+
|
|
213
|
+
ctx.save();
|
|
214
|
+
RoundedBox(ctx, 390, 145, progress, 50, Number(BarRadius));
|
|
215
|
+
ctx.strokeStyle = "#BFC85A22";
|
|
216
|
+
ctx.stroke();
|
|
217
|
+
ctx.clip();
|
|
218
|
+
ctx.fillStyle = LevelBarFill;
|
|
219
|
+
ctx.globalAlpha = 0.5;
|
|
220
|
+
ctx.fillRect(390, 145, progress, 50, 50);
|
|
221
|
+
ctx.restore();
|
|
222
|
+
|
|
223
|
+
ctx.save();
|
|
224
|
+
ctx.textAlign = "left";
|
|
225
|
+
ctx.fillStyle = "#ffffff";
|
|
226
|
+
ctx.globalAlpha = 0.8;
|
|
227
|
+
ctx.font = "30px \"Sans Serif\"";
|
|
228
|
+
ctx.fillText("Next Level: " + shortener(NeededXP) + " XP", 390, 230);
|
|
229
|
+
ctx.restore();
|
|
230
|
+
|
|
231
|
+
const latestXP = Number(CurrentXP) - Number(NeededXP);
|
|
232
|
+
const textXPEdited = TextXpNeded.replace(/{needed}/g, shortener(NeededXP).toString())
|
|
233
|
+
.replace(/{current}/g, shortener(CurrentXP).toString())
|
|
234
|
+
.replace(/{latest}/g, latestXP.toString());
|
|
235
|
+
ctx.textAlign = "center";
|
|
236
|
+
ctx.fillStyle = "#474747";
|
|
237
|
+
ctx.globalAlpha = 1;
|
|
238
|
+
ctx.font = "30px \"Sans Serif\"";
|
|
239
|
+
ctx.fillText(textXPEdited, 730, 180);
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
attachment: canvas.toBuffer("image/webp"),
|
|
243
|
+
description: AttachmentDesc,
|
|
244
|
+
name: AttachmentName
|
|
245
|
+
};
|
|
246
|
+
} catch (err) {
|
|
247
|
+
console.log(`[XP] Error Occured. | rankCard | Error: ${err.stack}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function RoundedBox(ctx, x, y, width, height, radius) {
|
|
253
|
+
ctx.beginPath();
|
|
254
|
+
ctx.moveTo(x + radius, y);
|
|
255
|
+
ctx.lineTo(x + width - radius, y);
|
|
256
|
+
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
|
|
257
|
+
ctx.lineTo(x + width, y + height - radius);
|
|
258
|
+
ctx.quadraticCurveTo(
|
|
259
|
+
x + width,
|
|
260
|
+
y + height,
|
|
261
|
+
x + width - radius,
|
|
262
|
+
y + height
|
|
263
|
+
);
|
|
264
|
+
ctx.lineTo(x + radius, y + height);
|
|
265
|
+
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
|
|
266
|
+
ctx.lineTo(x, y + radius);
|
|
267
|
+
ctx.quadraticCurveTo(x, y, x + radius, y);
|
|
268
|
+
ctx.closePath();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function shortener(count) {
|
|
272
|
+
const COUNT_ABBRS = [
|
|
273
|
+
"",
|
|
274
|
+
"k",
|
|
275
|
+
"M",
|
|
276
|
+
"B",
|
|
277
|
+
"T",
|
|
278
|
+
"Q",
|
|
279
|
+
"Q+",
|
|
280
|
+
"S",
|
|
281
|
+
"S+",
|
|
282
|
+
"O",
|
|
283
|
+
"N",
|
|
284
|
+
"D",
|
|
285
|
+
"U"
|
|
286
|
+
];
|
|
287
|
+
|
|
288
|
+
const i = 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000));
|
|
289
|
+
let result = parseFloat((count / Math.pow(1000, i)).toFixed(2));
|
|
290
|
+
result += `${COUNT_ABBRS[i]}`;
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
module.exports = rank;
|
|
295
|
+
|