apexify.js 2.4.2 → 2.4.4-beta.1

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.
@@ -1,840 +1,884 @@
1
- const { ApexPainter } = require('../ApexPainter');
2
- const painter = new ApexPainter();
3
-
4
- async function levelCard(message, userRecord) {
5
-
6
- const guild = await message.client.guilds.fetch(userRecord.guildId);
7
- const member = await guild.members.fetch(userRecord.userId);
8
- let user = {
9
- userId: userRecord.userId,
10
- xpCount: userRecord.xpCount,
11
- level: userRecord.level,
12
- guildId: userRecord.guildId,
13
- displayAvatarURL: member.user.displayAvatarURL(),
14
- };
15
-
16
- if (!member) {
17
- throw new Error(`Error: Couldn't find the user in this server.`);
18
- }
19
-
20
- if (!userRecord?.userId) {
21
- user.level = 0;
22
- throw new Error(`Error: Couldn't find data for this user.`);
23
- }
24
-
25
-
26
- const canvasOptions = {
27
- width: 1228,
28
- height: 300,
29
- customBg: 'https://media.discordapp.net/attachments/1172090817289134130/1174619005609332736/Picsart_23-11-09_17-28-24-812.png?ex=660522b2&is=65f2adb2&hm=83034f05e09f2278893aaf9a4bce75ef3581446d7e2449bc89485d12a42f3802&=&format=webp&quality=lossless&width=1228&height=300',
30
- borderRadius: 20,
31
- };
32
-
33
- const images = [
34
- {
35
- source: user.displayAvatarURL,
36
- borderRadius: 'circular',
37
- x: 97,
38
- y: 44,
39
- width: 210,
40
- height: 210,
41
- },
42
- ];
43
-
44
- const image = await painter.drawImages(images, canvasOptions);
45
-
46
- const prev = user.level - 1;
47
- const current = user.level;
48
-
49
- const getDynamicPrev = (text) => {
50
- const textLength = text.toString().length;
51
- if (textLength === 1) return 502;
52
- else if (textLength === 2) return 501;
53
- else if (textLength === 3) return 489;
54
- else return 484;
55
- };
56
-
57
- const getDynamicCurrent = (text) => {
58
- const textLength = text.toString().length;
59
- if (textLength === 1) return 949;
60
- else if (textLength === 2) return 941;
61
- else if (textLength === 3) return 940;
62
- else return 934;
63
- };
64
-
65
- const textOptionsArray = [
66
- {
67
- text: `${prev}`,
68
- x: getDynamicPrev(prev),
69
- y: 125,
70
- fontSize: 50,
71
- color: '#14cee7',
72
- stroke: {
73
- color: 'black',
74
- width: 0.5,
75
- },
76
- },
77
- {
78
- text: `${current}`,
79
- x: getDynamicCurrent(current),
80
- y: 125,
81
- fontSize: 50,
82
- color: '#14cee7',
83
- stroke: {
84
- color: 'black',
85
- width: 0.5,
86
- },
87
- },
88
- ];
89
-
90
- const card = await painter.addText(textOptionsArray, image, __dirname);
91
-
92
- return card;
93
- }
94
-
95
- async function xpRank(message, guildId, userId, level, rank, currentXp, nextXp, levelsArray, version, userBanner) {
96
-
97
- const guild = await message.client.guilds.fetch(guildId);
98
- const member = await guild.members.fetch(userId);
99
- let user = {
100
- displayAvatarURL: member.user.displayAvatarURL(),
101
- };
102
-
103
- if (!member) {
104
- throw new Error(`Error: Couldn't find the user in this server.`);
105
- }
106
-
107
-
108
- let xpBanner;
109
- if (userBanner && userBanner.startsWith('http')) {
110
- xpBanner = userBanner
111
- } else {
112
- xpBanner = 'https://t4.ftcdn.net/jpg/02/97/79/83/360_F_297798377_VB9egqGnRKcZxU53wybEHLRnnTrcvlAH.jpg';
113
- }
114
-
115
- const canvasOptions = {
116
- width: 588,
117
- height: 578,
118
- color: 'transparent',
119
- borderRadius: 0,
120
- };
121
-
122
- const loadingBarWidth = 293;
123
- const userCount = currentXp;
124
- const currentLevel = levelsArray.find((levelData) => userCount < levelData.xpCount)?.level || levelsArray.length - 1;
125
-
126
- const progress =
127
- (userCount - levelsArray[currentLevel - 1]?.xpCount) /
128
- (levelsArray[currentLevel].xpCount - levelsArray[currentLevel - 1]?.xpCount) *
129
- loadingBarWidth;
130
-
131
- const dynamicRank = (text) => {
132
- const textLength = text.toString().length;
133
- if (textLength === 1) return 482;
134
- else if (textLength === 2) return 455;
135
- else if (textLength === 3) return 445;
136
- else return 390;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
137
10
  };
138
-
139
- const images = [
140
- {
141
- source: 'square',
142
- borderRadius: 12,
143
- x: 56,
144
- y: 406,
145
- filled: true,
146
- color: 'white',
147
- width: 500,
148
- height: 180,
149
- },
150
- {
151
- source: xpBanner,
152
- borderRadius: 5,
153
- x: 18,
154
- y: 38,
155
- width: 552,
156
- height: 360,
157
- },
158
- {
159
- source: 'https://media.discordapp.net/attachments/1134572786262736996/1218231567793782794/image2.png?ex=6606e98f&is=65f4748f&hm=a2272aa02e7ff7ce6fcf6f6d64056c76c692f3a69533f4e4334347d35505393c&=&format=webp&quality=lossless&width=445&height=437',
160
- borderRadius: 5,
161
- x: 0,
162
- y: 0,
163
- width: 588,
164
- height: 578,
165
- },
166
- {
167
- source: user.displayAvatarURL,
168
- borderRadius: 'circular',
169
- x: 208,
170
- y: 123,
171
- width: 163,
172
- height: 163,
173
- stroke: {
174
- color: randomHex(),
175
- width: 5,
176
- borderRadius: 'circular',
177
- },
178
- },
179
- {
180
- source: guild.iconURL(),
181
- borderRadius: 'circular',
182
- x: 165,
183
- y: 43,
184
- width: 47,
185
- height: 47,
186
- },
187
- {
188
- source: 'square',
189
- borderRadius: 12,
190
- x: 56,
191
- y: 446,
192
- filled: true,
193
- color: '#5aa3ff',
194
- width: progress,
195
- height: 22,
196
- },
197
- {
198
- source: 'square',
199
- borderRadius: 12,
200
- x: 56,
201
- y: 518.5,
202
- filled: true,
203
- color: '#5aa3ff',
204
- width: 263,
205
- height: 22,
206
- },
207
- ];
208
-
209
- const image = await painter.drawImages(images, canvasOptions);
210
-
211
- const englishRegex = /[a-zA-Z]/;
212
- const arabicRegex = /[\u0600-\u06FF]/;
213
- const username = (member.user.globalName || member.user.username).substring(0, 12);
214
- const guildName = (guild.name).substring(0, 18);
215
-
216
- let fontName = '';
217
- let fontPath = '';
218
- let fontSize;
219
- let nameX;
220
-
221
- if (englishRegex.test(username)) {
222
- fontName = 'LevelFont eng';
223
- fontSize = 65;
224
- nameX = 200;
225
- fontPath = './levelFont.ttf';
226
- } else if (arabicRegex.test(username)) {
227
- fontName = 'LevelFont ara';
228
- fontSize = 65;
229
- nameX = 200 + 80;
230
- fontPath = 'level ara.ttf';
231
- } else {
232
- fontName = 'LevelFont eng';
233
- fontSize = 65;
234
- nameX = 200;
235
- fontPath = './levelFont.ttf';
236
- }
237
-
238
- let fontname = '';
239
- let fontpath = '';
240
- let fontsize;
241
- let namex;
242
- let textAlign;
243
-
244
- if (englishRegex.test(guildName)) {
245
- fontname = 'LevelFont eng';
246
- fontsize = 25;
247
- namex = 220;
248
- textAlign = "left";
249
- fontpath = './levelFont.ttf';
250
- } else if (arabicRegex.test(guildName)) {
251
- fontname = 'LevelFont ara';
252
- fontsize = 25;
253
- namex = 200 + 55;
254
- textAlign = "right",
255
- fontpath = 'level ara.ttf';
256
- } else {
257
- fontname = 'LevelFont eng';
258
- fontsize = 25;
259
- namex = 220;
260
- textAlign = "left";
261
- fontpath = './levelFont.ttf';
262
- }
263
-
264
- const textOptionsArray = [
265
- {
266
- text: `${level}`,
267
- x: 185,
268
- y: 418,
269
- fontSize: 30,
270
- fontName: 'numbers',
271
- fontPath: './numbers.ttf',
272
- color: 'white',
273
- stroke: {
274
- color: 'black',
275
- width: 0.6,
276
- },
277
- },
278
- {
279
- text: `${currentXp}/${nextXp}`,
280
- x: 142,
281
- y: 450,
282
- fontSize: 22,
283
- fontName: 'numbers',
284
- fontPath: './numbers.ttf',
285
- color: 'black',
286
- stroke: {
287
- color: 'black',
288
- width: 0.5,
289
- },
290
- shadow: {
291
- offsetX: 2,
292
- offsetY: 2,
293
- color: 'white',
294
- opacity: 0.1,
295
- blur: 2,
296
- },
297
- },
298
- {
299
- text: `${rank}`,
300
- x: dynamicRank(rank),
301
- y: 460,
302
- fontSize: 70,
303
- fontName: 'numbers',
304
- fontPath: './numbers.ttf',
305
- color: '#ffffff',
306
- stroke: {
307
- color: 'black',
308
- width: 0.6,
309
- },
310
- shadow: {
311
- offsetX: 2,
312
- offsetY: 2,
313
- color: 'black',
314
- opacity: 0.5,
315
- blur: 10,
316
- },
317
- },
318
- {
319
- text: `Coming Soon...`,
320
- x: 202,
321
- y: 490,
322
- fontSize: 23,
323
- fontName: 'levelFont eng',
324
- fontPath: './levelFont.ttf',
325
- color: '#ffffff',
326
- stroke: {
327
- color: 'black',
328
- width: 0.5,
329
- },
330
- shadow: {
331
- offsetX: 2,
332
- offsetY: 2,
333
- color: 'black',
334
- opacity: 0.5,
335
- blur: 10,
336
- },
337
- },
338
- {
339
- text: `Coming Soon...`,
340
- x: 135,
341
- y: 522,
342
- fontSize: 23,
343
- fontName: 'nubers',
344
- fontPath: './numbers.ttf',
345
- color: '#706f6f',
346
- stroke: {
347
- color: 'black',
348
- width: 0.5,
349
- },
350
- },
351
- {
352
- text: `${username}`,
353
- x: nameX,
354
- y: 320,
355
- fontSize: fontSize,
356
- fontName: fontName,
357
- fontPath: fontPath,
358
- color: 'white',
359
- stroke: {
360
- color: 'black',
361
- width: 0.5,
362
- },
363
- },
364
- {
365
- text: `${guildName}`,
366
- x: namex,
367
- y: 52,
368
- fontSize: fontsize,
369
- fontName: fontname,
370
- fontPath: fontpath,
371
- textAlign: textAlign,
372
- color: 'white',
373
- stroke: {
374
- color: 'black',
375
- width: 0.5,
376
- },
377
- },
378
- ];
379
-
380
- const card = await painter.addText(textOptionsArray, image, __dirname);
381
-
382
- return card;
383
- }
384
-
385
- async function leaderBoard(message, results, version, colorHex) {
386
-
387
- if (version === 1) {
388
-
389
- const canvasOptions = {
390
- width: 959,
391
- height: 706,
392
- x: 0,
393
- y: 0,
394
- customBg: 'https://media.discordapp.net/attachments/1172090817289134130/1174551957696946218/Picsart_23-11-12_08-56-51-193.jpg?ex=6604e440&is=65f26f40&hm=e59c6de9d80551f92f40b81ae0808dd602351f312e23965943cfda6acfcdcbea&=&format=webp&width=759&height=506',
395
- borderRadius: 10,
396
- };
397
-
398
- let images = [];
399
- let textOptionsArray = [];
400
-
401
-
402
- for (let i = 0; i < results.length; i++) {
403
- const userRecord = results[i];
404
- let guild;
405
- if (message.client) {
406
- guild = await message.client.guilds.fetch(userRecord.guildId)
407
- } else {
408
- guild = await message.guilds.fetch(results[0].guildId);
409
- }
410
- const member = await guild.members.fetch(userRecord.userId);
411
-
412
- const user = {
413
- userId: userRecord.userId,
414
- xpCount: userRecord.xpCount,
415
- level: userRecord.level,
416
- guildId: userRecord.guildId,
417
- displayAvatarURL: member.user.displayAvatarURL(),
418
- username: member.user.globalName || member.user.username,
419
- };
420
-
421
- let avatarX = 120;
422
- let avatarY = 102 + (63 + 20) * images.length;
423
- let fontY = 120 + (63 + 19) * images.length;
424
- let lvy = 122 + (63 + 19) * images.length;
425
- if (i === 2) {
426
- avatarY -= 12;
427
- fontY -= 10;
428
- lvy -= 10;
429
- } else if (i === 3) {
430
- avatarY -= 16;
431
- fontY -= 16;
432
- lvy -= 16;
433
- } else if (i === 4) {
434
- avatarY -= 19;
435
- fontY -= 19;
436
- lvy -= 19;
437
- }
438
-
439
- images.push({
440
- source: user.displayAvatarURL,
441
- borderRadius: 'circular',
442
- x: avatarX,
443
- y: avatarY,
444
- width: 63,
445
- height: 63,
446
- });
447
-
448
- textOptionsArray.push(
449
- {
450
- text: `${user.username.slice(0, 9).trim()}`,
451
- x: 210,
452
- y: fontY,
453
- fontSize: 30,
454
- color: '#14cee7',
455
- stroke: {
456
- color: 'black',
457
- width: 0.5,
458
- },
459
- shadow: {
460
- offsetX: 3,
461
- offsetY: 3,
462
- color: "rgba(0, 0, 0, 0.8)",
463
- opacity: 0.4,
464
- blur: 5
465
- },
466
- },
467
- {
468
- text: `Level: ${user.level}`,
469
- x: 370,
470
- y: lvy,
471
- fontSize: 25,
472
- color: '#14cee7',
473
- stroke: {
474
- color: 'black',
475
- width: 0.5,
476
- },
477
- shadow: {
478
- offsetX: 3,
479
- offsetY: 3,
480
- color: "rgba(0, 0, 0, 0.8)",
481
- opacity: 0.3,
482
- blur: 5
483
- },
484
- },
485
- {
486
- text: `Xp: ${user.xpCount}`,
487
- x: 505,
488
- y: lvy + 5,
489
- fontSize: 18,
490
- color: '#14cee7',
491
- stroke: {
492
- color: 'black',
493
- width: 0.5,
494
- },
495
- shadow: {
496
- offsetX: 3,
497
- offsetY: 3,
498
- color: "rgba(0, 0, 0, 0.8)",
499
- opacity: 0.3,
500
- blur: 5
501
- },
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
502
36
  }
503
- );
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.xpRank = exports.leaderBoard = exports.levelCard = void 0;
40
+ var ApexPainter_1 = require("../ApexPainter");
41
+ var painter = new ApexPainter_1.ApexPainter();
42
+ function levelCard(message, userRecord) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var guild, member, canvasOptions, images, image, prev, current, getDynamicPrev, getDynamicCurrent, textOptionsArray, card;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, message.client.guilds.fetch(userRecord.guildId)];
48
+ case 1:
49
+ guild = _a.sent();
50
+ return [4 /*yield*/, guild.members.fetch(userRecord.userId)];
51
+ case 2:
52
+ member = _a.sent();
53
+ if (!member) {
54
+ throw new Error("Error: Couldn't find the user in this server.");
55
+ }
56
+ if (!(userRecord === null || userRecord === void 0 ? void 0 : userRecord.userId)) {
57
+ userRecord.level = 0;
58
+ throw new Error("Error: Couldn't find data for this user.");
59
+ }
60
+ canvasOptions = {
61
+ width: 1228,
62
+ height: 300,
63
+ customBg: 'https://media.discordapp.net/attachments/1172090817289134130/1174619005609332736/Picsart_23-11-09_17-28-24-812.png?ex=660522b2&is=65f2adb2&hm=83034f05e09f2278893aaf9a4bce75ef3581446d7e2449bc89485d12a42f3802&=&format=webp&quality=lossless&width=1228&height=300',
64
+ borderRadius: 20,
65
+ };
66
+ images = [
67
+ {
68
+ source: member?.user?.displayAvatarURL || 'https://styles.redditmedia.com/t5_388p4/styles/communityIcon_1xjv62tivxy61.png',
69
+ borderRadius: 'circular',
70
+ x: 97,
71
+ y: 44,
72
+ width: 210,
73
+ height: 210,
74
+ },
75
+ ];
76
+ return [4 /*yield*/, painter.drawImages(images, canvasOptions)];
77
+ case 3:
78
+ image = _a.sent();
79
+ prev = userRecord.level - 1;
80
+ current = userRecord.level;
81
+ getDynamicPrev = function (text) {
82
+ var textLength = text.toString().length;
83
+ if (textLength === 1)
84
+ return 520;
85
+ else if (textLength === 2)
86
+ return 501;
87
+ else if (textLength === 3)
88
+ return 489;
89
+ else
90
+ return 484;
91
+ };
92
+ getDynamicCurrent = function (text) {
93
+ var textLength = text.toString().length;
94
+ if (textLength === 1)
95
+ return 959;
96
+ else if (textLength === 2)
97
+ return 941;
98
+ else if (textLength === 3)
99
+ return 940;
100
+ else
101
+ return 934;
102
+ };
103
+ textOptionsArray = [
104
+ {
105
+ text: "".concat(prev),
106
+ x: getDynamicPrev(prev),
107
+ y: 125,
108
+ fontSize: 50,
109
+ color: '#14cee7',
110
+ stroke: {
111
+ color: 'black',
112
+ width: 0.5,
113
+ },
114
+ },
115
+ {
116
+ text: "".concat(current),
117
+ x: getDynamicCurrent(current),
118
+ y: 125,
119
+ fontSize: 50,
120
+ color: '#14cee7',
121
+ stroke: {
122
+ color: 'black',
123
+ width: 0.5,
124
+ },
125
+ },
126
+ ];
127
+ return [4 /*yield*/, painter.addText(textOptionsArray, image, __dirname)];
128
+ case 4:
129
+ card = _a.sent();
130
+ return [2 /*return*/, card];
131
+ }
132
+ });
133
+ });
504
134
  }
505
-
506
- const image = await painter.drawImages(images, canvasOptions);
507
-
508
- const card = await painter.addText(textOptionsArray, image, __dirname);
509
-
510
- return card;
511
- } else if (version === 2) {
512
-
513
- const canvasOptions = {
514
- width: 600,
515
- height: 600,
516
- x: 0,
517
- y: 0,
518
- customBg: 'https://media.discordapp.net/attachments/1131285544740061266/1212243800496275546/leaderboard.webp?ex=66039604&is=65f12104&hm=9dea66607a66fe9413754b912a6ae4b62c65b1ed772dcd5444bbb7d14a2a2fdb&=&format=webp&width=578&height=578',
519
- borderRadius: 10,
520
- };
521
-
522
- const images = [];
523
- const textOptionsArray = [];
524
-
525
- for (const userRecord of results) {
526
- let guild;
527
- if (message.client) {
528
- guild = await message.client.guilds.fetch(userRecord.guildId)
529
- } else {
530
- guild = await message.guilds.fetch(results[0].guildId);
531
- }
532
- const member = await guild.members.fetch(userRecord.userId);
533
-
534
- const user = {
535
- userId: userRecord.userId,
536
- xpCount: userRecord.xpCount,
537
- level: userRecord.level,
538
- guildId: userRecord.guildId,
539
- displayAvatarURL: member.user.displayAvatarURL(),
540
- username: member.user.globalName || member.user.username,
541
- };
542
-
543
- const englishRegex = /[a-zA-Z]/;
544
- const arabicRegex = /[\u0600-\u06FF]/;
545
- const username = user.username;
546
-
547
- let fontName = '';
548
- let fontPath = '';
549
- let fontSize;
550
-
551
- if (englishRegex.test(username)) {
552
- fontName = 'LevelFont eng';
553
- fontSize = 28;
554
- fontPath = './levelFont.ttf';
555
- } else if (arabicRegex.test(username)) {
556
- fontName = 'LevelFont ara';
557
- fontSize = 28;
558
- fontPath = 'level ara.ttf';
559
- } else {
560
- fontName = 'LevelFont eng';
561
- fontSize = 28;
562
- fontPath = './levelFont.ttf';
135
+ exports.levelCard = levelCard;
136
+ function xpRank(message, guildId, userId, level, rank, currentXp, nextXp, levelsArray, version, userBanner) {
137
+ var _a, _b, _c;
138
+ return __awaiter(this, void 0, void 0, function () {
139
+ var guild, member, user, xpBanner, canvasOptions, loadingBarWidth, userCount, currentLevel, progress, dynamicRank, images, image, englishRegex, arabicRegex, username, guildName, fontName, fontPath, fontSize, nameX, fontname, fontpath, fontsize, namex, textAlign, textOptionsArray, card;
140
+ return __generator(this, function (_d) {
141
+ switch (_d.label) {
142
+ case 0: return [4 /*yield*/, message.client.guilds.fetch(guildId)];
143
+ case 1:
144
+ guild = _d.sent();
145
+ return [4 /*yield*/, guild.members.fetch(userId)];
146
+ case 2:
147
+ member = _d.sent();
148
+ user = {
149
+ displayAvatarURL: member.user.displayAvatarURL(),
150
+ };
151
+ if (!member) {
152
+ throw new Error("Error: Couldn't find the user in this server.");
153
+ }
154
+ if (userBanner && userBanner.startsWith('http')) {
155
+ xpBanner = userBanner;
156
+ }
157
+ else {
158
+ xpBanner = 'https://t4.ftcdn.net/jpg/02/97/79/83/360_F_297798377_VB9egqGnRKcZxU53wybEHLRnnTrcvlAH.jpg';
159
+ }
160
+ canvasOptions = {
161
+ width: 588,
162
+ height: 578,
163
+ color: 'transparent',
164
+ borderRadius: 0,
165
+ };
166
+ loadingBarWidth = 293;
167
+ userCount = currentXp;
168
+ currentLevel = ((_a = levelsArray.find(function (levelData) { return userCount < levelData.xpCount; })) === null || _a === void 0 ? void 0 : _a.level) || levelsArray.length - 1;
169
+ progress = (userCount - ((_b = levelsArray[currentLevel - 1]) === null || _b === void 0 ? void 0 : _b.xpCount)) /
170
+ (levelsArray[currentLevel].xpCount - ((_c = levelsArray[currentLevel - 1]) === null || _c === void 0 ? void 0 : _c.xpCount)) *
171
+ loadingBarWidth;
172
+ dynamicRank = function (text) {
173
+ var textLength = text.toString().length;
174
+ if (textLength === 1)
175
+ return 482;
176
+ else if (textLength === 2)
177
+ return 455;
178
+ else if (textLength === 3)
179
+ return 445;
180
+ else
181
+ return 390;
182
+ };
183
+ images = [
184
+ {
185
+ source: 'square',
186
+ borderRadius: 12,
187
+ x: 56,
188
+ y: 406,
189
+ filled: true,
190
+ color: 'white',
191
+ width: 500,
192
+ height: 180,
193
+ },
194
+ {
195
+ source: xpBanner,
196
+ borderRadius: 5,
197
+ x: 18,
198
+ y: 38,
199
+ width: 552,
200
+ height: 360,
201
+ },
202
+ {
203
+ source: 'https://media.discordapp.net/attachments/1134572786262736996/1218231567793782794/image2.png?ex=6606e98f&is=65f4748f&hm=a2272aa02e7ff7ce6fcf6f6d64056c76c692f3a69533f4e4334347d35505393c&=&format=webp&quality=lossless&width=445&height=437',
204
+ borderRadius: 5,
205
+ x: 0,
206
+ y: 0,
207
+ width: 588,
208
+ height: 578,
209
+ },
210
+ {
211
+ source: user.displayAvatarURL,
212
+ borderRadius: 'circular',
213
+ x: 208,
214
+ y: 123,
215
+ width: 163,
216
+ height: 163,
217
+ stroke: {
218
+ color: randomHex(),
219
+ width: 5,
220
+ borderRadius: 'circular',
221
+ },
222
+ },
223
+ {
224
+ source: guild.iconURL(),
225
+ borderRadius: 'circular',
226
+ x: 165,
227
+ y: 43,
228
+ width: 47,
229
+ height: 47,
230
+ },
231
+ {
232
+ source: 'square',
233
+ borderRadius: 12,
234
+ x: 56,
235
+ y: 446,
236
+ filled: true,
237
+ color: '#5aa3ff',
238
+ width: progress,
239
+ height: 22,
240
+ },
241
+ {
242
+ source: 'square',
243
+ borderRadius: 12,
244
+ x: 56,
245
+ y: 518.5,
246
+ filled: true,
247
+ color: '#5aa3ff',
248
+ width: 263,
249
+ height: 22,
250
+ },
251
+ ];
252
+ return [4 /*yield*/, painter.drawImages(images, canvasOptions)];
253
+ case 3:
254
+ image = _d.sent();
255
+ englishRegex = /[a-zA-Z]/;
256
+ arabicRegex = /[\u0600-\u06FF]/;
257
+ username = (member.user.globalName || member.user.username).substring(0, 12);
258
+ guildName = (guild.name).substring(0, 18);
259
+ fontName = '';
260
+ fontPath = '';
261
+ if (englishRegex.test(username)) {
262
+ fontName = 'LevelFont eng';
263
+ fontSize = 65;
264
+ nameX = 200;
265
+ fontPath = './levelFont.ttf';
266
+ }
267
+ else if (arabicRegex.test(username)) {
268
+ fontName = 'LevelFont ara';
269
+ fontSize = 65;
270
+ nameX = 200 + 80;
271
+ fontPath = 'level ara.ttf';
272
+ }
273
+ else {
274
+ fontName = 'LevelFont eng';
275
+ fontSize = 65;
276
+ nameX = 200;
277
+ fontPath = './levelFont.ttf';
278
+ }
279
+ fontname = '';
280
+ fontpath = '';
281
+ if (englishRegex.test(guildName)) {
282
+ fontname = 'LevelFont eng';
283
+ fontsize = 25;
284
+ namex = 220;
285
+ textAlign = "left";
286
+ fontpath = './levelFont.ttf';
287
+ }
288
+ else if (arabicRegex.test(guildName)) {
289
+ fontname = 'LevelFont ara';
290
+ fontsize = 25;
291
+ namex = 200 + 55;
292
+ textAlign = "right",
293
+ fontpath = 'level ara.ttf';
294
+ }
295
+ else {
296
+ fontname = 'LevelFont eng';
297
+ fontsize = 25;
298
+ namex = 220;
299
+ textAlign = "left";
300
+ fontpath = './levelFont.ttf';
301
+ }
302
+ textOptionsArray = [
303
+ {
304
+ text: "".concat(level),
305
+ x: 185,
306
+ y: 418,
307
+ fontSize: 30,
308
+ fontName: 'numbers',
309
+ fontPath: './numbers.ttf',
310
+ color: 'white',
311
+ stroke: {
312
+ color: 'black',
313
+ width: 0.6,
314
+ },
315
+ },
316
+ {
317
+ text: "".concat(currentXp, "/").concat(nextXp),
318
+ x: 142,
319
+ y: 450,
320
+ fontSize: 22,
321
+ fontName: 'numbers',
322
+ fontPath: './numbers.ttf',
323
+ color: 'black',
324
+ stroke: {
325
+ color: 'black',
326
+ width: 0.5,
327
+ },
328
+ shadow: {
329
+ offsetX: 2,
330
+ offsetY: 2,
331
+ color: 'white',
332
+ opacity: 0.1,
333
+ blur: 2,
334
+ },
335
+ },
336
+ {
337
+ text: "".concat(rank),
338
+ x: dynamicRank(rank),
339
+ y: 460,
340
+ fontSize: 70,
341
+ fontName: 'numbers',
342
+ fontPath: './numbers.ttf',
343
+ color: '#ffffff',
344
+ stroke: {
345
+ color: 'black',
346
+ width: 0.6,
347
+ },
348
+ shadow: {
349
+ offsetX: 2,
350
+ offsetY: 2,
351
+ color: 'black',
352
+ opacity: 0.5,
353
+ blur: 10,
354
+ },
355
+ },
356
+ {
357
+ text: "Coming Soon...",
358
+ x: 202,
359
+ y: 490,
360
+ fontSize: 23,
361
+ fontName: 'levelFont eng',
362
+ fontPath: './levelFont.ttf',
363
+ color: '#ffffff',
364
+ stroke: {
365
+ color: 'black',
366
+ width: 0.5,
367
+ },
368
+ shadow: {
369
+ offsetX: 2,
370
+ offsetY: 2,
371
+ color: 'black',
372
+ opacity: 0.5,
373
+ blur: 10,
374
+ },
375
+ },
376
+ {
377
+ text: "Coming Soon...",
378
+ x: 135,
379
+ y: 522,
380
+ fontSize: 23,
381
+ fontName: 'nubers',
382
+ fontPath: './numbers.ttf',
383
+ color: '#706f6f',
384
+ stroke: {
385
+ color: 'black',
386
+ width: 0.5,
387
+ },
388
+ },
389
+ {
390
+ text: "".concat(username),
391
+ x: nameX,
392
+ y: 320,
393
+ fontSize: fontSize,
394
+ fontName: fontName,
395
+ fontPath: fontPath,
396
+ color: 'white',
397
+ stroke: {
398
+ color: 'black',
399
+ width: 0.5,
400
+ },
401
+ },
402
+ {
403
+ text: "".concat(guildName),
404
+ x: namex,
405
+ y: 52,
406
+ fontSize: fontsize,
407
+ fontName: fontname,
408
+ fontPath: fontpath,
409
+ textAlign: textAlign,
410
+ color: 'white',
411
+ stroke: {
412
+ color: 'black',
413
+ width: 0.5,
414
+ },
415
+ },
416
+ ];
417
+ return [4 /*yield*/, painter.addText(textOptionsArray, image, __dirname)];
418
+ case 4:
419
+ card = _d.sent();
420
+ return [2 /*return*/, card];
421
+ }
422
+ });
423
+ });
563
424
  }
564
-
565
- const dynamicLevel = (text) => {
566
- const textLength = text.toString().length;
567
- if (textLength === 1) return 417;
568
- else if (textLength === 2) return 411;
569
- else if (textLength === 3) return 398;
570
- else return 390;
571
- };
572
-
573
- let colorText;
574
-
575
- if (colorHex !== 'random') {
576
- colorText = colorHex;
577
- } else if (colorHex === 'random') {
578
- colorText = randomHex();
579
- } else {
580
- colorText = randomHex();
581
- }
582
-
583
- images.push({
584
- source: user.displayAvatarURL,
585
- borderRadius: 'circular',
586
- x: 38,
587
- y: 138.5 + (60 + 10.5) * images.length,
588
- width: 61,
589
- height: 61,
590
- stroke: {
591
- color: randomHex(),
592
- width: 3,
593
- borderRadius: 'circular',
594
- }
425
+ exports.xpRank = xpRank;
426
+ function leaderBoard(message, results, version, colorHex) {
427
+ return __awaiter(this, void 0, void 0, function () {
428
+ var canvasOptions, images, textOptionsArray, i, userRecord, guild, member, user, avatarX, avatarY, fontY, lvy, image, card, canvasOptions, images, textOptionsArray, _i, results_1, userRecord, guild, member, user, englishRegex, arabicRegex, username, fontName, fontPath, fontSize, dynamicLevel, colorText, image, card, resizeOptions, resizedImageBuffer;
429
+ return __generator(this, function (_a) {
430
+ switch (_a.label) {
431
+ case 0:
432
+ if (!(version === 1)) return [3 /*break*/, 11];
433
+ canvasOptions = {
434
+ width: 959,
435
+ height: 706,
436
+ x: 0,
437
+ y: 0,
438
+ customBg: 'https://media.discordapp.net/attachments/1172090817289134130/1174551957696946218/Picsart_23-11-12_08-56-51-193.jpg?ex=6604e440&is=65f26f40&hm=e59c6de9d80551f92f40b81ae0808dd602351f312e23965943cfda6acfcdcbea&=&format=webp&width=759&height=506',
439
+ borderRadius: 10,
440
+ };
441
+ images = [];
442
+ textOptionsArray = [];
443
+ i = 0;
444
+ _a.label = 1;
445
+ case 1:
446
+ if (!(i < results.length)) return [3 /*break*/, 8];
447
+ userRecord = results[i];
448
+ guild = void 0;
449
+ if (!message.client) return [3 /*break*/, 3];
450
+ return [4 /*yield*/, message.client.guilds.fetch(userRecord.guildId)];
451
+ case 2:
452
+ guild = _a.sent();
453
+ return [3 /*break*/, 5];
454
+ case 3: return [4 /*yield*/, message.guilds.fetch(results[0].guildId)];
455
+ case 4:
456
+ guild = _a.sent();
457
+ _a.label = 5;
458
+ case 5: return [4 /*yield*/, guild.members.fetch(userRecord.userId)];
459
+ case 6:
460
+ member = _a.sent();
461
+ user = {
462
+ userId: userRecord.userId,
463
+ xpCount: userRecord.xpCount,
464
+ level: userRecord.level,
465
+ guildId: userRecord.guildId,
466
+ displayAvatarURL: member.user.displayAvatarURL(),
467
+ username: member.user.globalName || member.user.username,
468
+ };
469
+ avatarX = 120;
470
+ avatarY = 102 + (63 + 20) * images.length;
471
+ fontY = 120 + (63 + 19) * images.length;
472
+ lvy = 122 + (63 + 19) * images.length;
473
+ if (i === 2) {
474
+ avatarY -= 12;
475
+ fontY -= 10;
476
+ lvy -= 10;
477
+ }
478
+ else if (i === 3) {
479
+ avatarY -= 16;
480
+ fontY -= 16;
481
+ lvy -= 16;
482
+ }
483
+ else if (i === 4) {
484
+ avatarY -= 19;
485
+ fontY -= 19;
486
+ lvy -= 19;
487
+ }
488
+ images.push({
489
+ source: user.displayAvatarURL,
490
+ borderRadius: 'circular',
491
+ x: avatarX,
492
+ y: avatarY,
493
+ width: 63,
494
+ height: 63,
495
+ });
496
+ textOptionsArray.push({
497
+ text: "".concat(user.username.slice(0, 9).trim()),
498
+ x: 210,
499
+ y: fontY,
500
+ fontSize: 30,
501
+ color: '#14cee7',
502
+ stroke: {
503
+ color: 'black',
504
+ width: 0.5,
505
+ },
506
+ shadow: {
507
+ offsetX: 3,
508
+ offsetY: 3,
509
+ color: "rgba(0, 0, 0, 0.8)",
510
+ opacity: 0.4,
511
+ blur: 5
512
+ },
513
+ }, {
514
+ text: "Level: ".concat(user.level),
515
+ x: 370,
516
+ y: lvy,
517
+ fontSize: 25,
518
+ color: '#14cee7',
519
+ stroke: {
520
+ color: 'black',
521
+ width: 0.5,
522
+ },
523
+ shadow: {
524
+ offsetX: 3,
525
+ offsetY: 3,
526
+ color: "rgba(0, 0, 0, 0.8)",
527
+ opacity: 0.3,
528
+ blur: 5
529
+ },
530
+ }, {
531
+ text: "Xp: ".concat(user.xpCount),
532
+ x: 505,
533
+ y: lvy + 5,
534
+ fontSize: 18,
535
+ color: '#14cee7',
536
+ stroke: {
537
+ color: 'black',
538
+ width: 0.5,
539
+ },
540
+ shadow: {
541
+ offsetX: 3,
542
+ offsetY: 3,
543
+ color: "rgba(0, 0, 0, 0.8)",
544
+ opacity: 0.3,
545
+ blur: 5
546
+ },
547
+ });
548
+ _a.label = 7;
549
+ case 7:
550
+ i++;
551
+ return [3 /*break*/, 1];
552
+ case 8: return [4 /*yield*/, painter.drawImages(images, canvasOptions)];
553
+ case 9:
554
+ image = _a.sent();
555
+ return [4 /*yield*/, painter.addText(textOptionsArray, image, __dirname)];
556
+ case 10:
557
+ card = _a.sent();
558
+ return [2 /*return*/, card];
559
+ case 11:
560
+ if (!(version === 2)) return [3 /*break*/, 23];
561
+ canvasOptions = {
562
+ width: 600,
563
+ height: 600,
564
+ x: 0,
565
+ y: 0,
566
+ customBg: 'https://media.discordapp.net/attachments/1131285544740061266/1212243800496275546/leaderboard.webp?ex=66039604&is=65f12104&hm=9dea66607a66fe9413754b912a6ae4b62c65b1ed772dcd5444bbb7d14a2a2fdb&=&format=webp&width=578&height=578',
567
+ borderRadius: 10,
568
+ };
569
+ images = [];
570
+ textOptionsArray = [];
571
+ _i = 0, results_1 = results;
572
+ _a.label = 12;
573
+ case 12:
574
+ if (!(_i < results_1.length)) return [3 /*break*/, 19];
575
+ userRecord = results_1[_i];
576
+ guild = void 0;
577
+ if (!message.client) return [3 /*break*/, 14];
578
+ return [4 /*yield*/, message.client.guilds.fetch(userRecord.guildId)];
579
+ case 13:
580
+ guild = _a.sent();
581
+ return [3 /*break*/, 16];
582
+ case 14: return [4 /*yield*/, message.guilds.fetch(results[0].guildId)];
583
+ case 15:
584
+ guild = _a.sent();
585
+ _a.label = 16;
586
+ case 16: return [4 /*yield*/, guild.members.fetch(userRecord.userId)];
587
+ case 17:
588
+ member = _a.sent();
589
+ user = {
590
+ userId: userRecord.userId,
591
+ xpCount: userRecord.xpCount,
592
+ level: userRecord.level,
593
+ guildId: userRecord.guildId,
594
+ displayAvatarURL: member.user.displayAvatarURL(),
595
+ username: member.user.globalName || member.user.username,
596
+ };
597
+ englishRegex = /[a-zA-Z]/;
598
+ arabicRegex = /[\u0600-\u06FF]/;
599
+ username = user.username;
600
+ fontName = '';
601
+ fontPath = '';
602
+ fontSize = void 0;
603
+ if (englishRegex.test(username)) {
604
+ fontName = 'LevelFont eng';
605
+ fontSize = 28;
606
+ fontPath = './levelFont.ttf';
607
+ }
608
+ else if (arabicRegex.test(username)) {
609
+ fontName = 'LevelFont ara';
610
+ fontSize = 28;
611
+ fontPath = 'level ara.ttf';
612
+ }
613
+ else {
614
+ fontName = 'LevelFont eng';
615
+ fontSize = 28;
616
+ fontPath = './levelFont.ttf';
617
+ }
618
+ dynamicLevel = function (text) {
619
+ var textLength = text.toString().length;
620
+ if (textLength === 1)
621
+ return 417;
622
+ else if (textLength === 2)
623
+ return 411;
624
+ else if (textLength === 3)
625
+ return 398;
626
+ else
627
+ return 390;
628
+ };
629
+ colorText = void 0;
630
+ if (colorHex !== 'random') {
631
+ colorText = colorHex;
632
+ }
633
+ else if (colorHex === 'random') {
634
+ colorText = randomHex();
635
+ }
636
+ else {
637
+ colorText = randomHex();
638
+ }
639
+ images.push({
640
+ source: user.displayAvatarURL,
641
+ borderRadius: 'circular',
642
+ x: 38,
643
+ y: 138.5 + (60 + 10.5) * images.length,
644
+ width: 61,
645
+ height: 61,
646
+ stroke: {
647
+ color: randomHex(),
648
+ width: 3,
649
+ borderRadius: 'circular',
650
+ }
651
+ });
652
+ textOptionsArray.push({
653
+ text: "SERVER LEADERBOARD",
654
+ x: 55,
655
+ y: 16,
656
+ fontSize: 55,
657
+ fontName: 'LevelFont eng',
658
+ fontPath: './levelFont.ttf',
659
+ color: '#14cee7',
660
+ stroke: {
661
+ color: 'black',
662
+ width: 0.5,
663
+ },
664
+ shadow: {
665
+ offsetX: 3,
666
+ offsetY: 3,
667
+ color: "rgba(0, 0, 0, 0.8)",
668
+ opacity: 0.4,
669
+ blur: 5
670
+ },
671
+ }, {
672
+ text: "pfp",
673
+ x: 52,
674
+ y: 87,
675
+ fontSize: 25,
676
+ fontName: 'LevelFont eng',
677
+ fontPath: './levelFont.ttf',
678
+ color: 'white',
679
+ stroke: {
680
+ color: 'black',
681
+ width: 0.5,
682
+ },
683
+ }, {
684
+ text: "USERNAME",
685
+ x: 185,
686
+ y: 87,
687
+ fontSize: 30,
688
+ fontName: 'LevelFont eng',
689
+ fontPath: './levelFont.ttf',
690
+ color: 'white',
691
+ stroke: {
692
+ color: 'black',
693
+ width: 0.5,
694
+ },
695
+ }, {
696
+ text: "LEVEL",
697
+ x: 395,
698
+ y: 92,
699
+ fontSize: 25,
700
+ fontName: 'LevelFont eng',
701
+ fontPath: './levelFont.ttf',
702
+ color: 'white',
703
+ stroke: {
704
+ color: 'black',
705
+ width: 0.5,
706
+ },
707
+ }, {
708
+ text: "RANK",
709
+ x: 472,
710
+ y: 92,
711
+ fontSize: 25,
712
+ fontName: 'LevelFont eng',
713
+ fontPath: './levelFont.ttf',
714
+ color: 'white',
715
+ stroke: {
716
+ color: 'black',
717
+ width: 0.5,
718
+ },
719
+ }, {
720
+ text: "".concat(user.username.slice(0, 9).trim()),
721
+ x: 145,
722
+ y: 83 + (32 + 38) * images.length,
723
+ fontSize: fontSize + 6,
724
+ fontName: fontName,
725
+ fontPath: fontPath,
726
+ color: colorText,
727
+ stroke: {
728
+ color: 'black',
729
+ width: 0.5,
730
+ },
731
+ shadow: {
732
+ offsetX: 3,
733
+ offsetY: 3,
734
+ color: "rgba(0, 0, 0, 0.8)",
735
+ opacity: 0.4,
736
+ blur: 5
737
+ },
738
+ }, {
739
+ text: "".concat(user.level),
740
+ x: dynamicLevel(user.level),
741
+ y: 85 + (32 + 38) * images.length,
742
+ fontSize: 35,
743
+ fontName: 'LevelFont eng',
744
+ fontPath: './levelFont.ttf',
745
+ color: colorText,
746
+ stroke: {
747
+ color: 'black',
748
+ width: 0.5,
749
+ },
750
+ shadow: {
751
+ offsetX: 3,
752
+ offsetY: 3,
753
+ color: "rgba(0, 0, 0, 0.8)",
754
+ opacity: 0.3,
755
+ blur: 5
756
+ },
757
+ }, {
758
+ text: "#1",
759
+ x: 475,
760
+ y: 157,
761
+ fontSize: 32,
762
+ fontName: 'LevelFont eng',
763
+ fontPath: './levelFont.ttf',
764
+ color: '#ffd700',
765
+ stroke: {
766
+ color: 'black',
767
+ width: 0.6,
768
+ },
769
+ shadow: {
770
+ offsetX: 3,
771
+ offsetY: 3,
772
+ color: "rgba(0, 0, 0, 0.6)",
773
+ opacity: 0.3,
774
+ blur: 5
775
+ },
776
+ }, {
777
+ text: "#2",
778
+ x: 475,
779
+ y: 225,
780
+ fontSize: 32,
781
+ fontName: 'LevelFont eng',
782
+ fontPath: './levelFont.ttf',
783
+ color: '#bababa',
784
+ stroke: {
785
+ color: 'black',
786
+ width: 0.4,
787
+ },
788
+ shadow: {
789
+ offsetX: 3,
790
+ offsetY: 3,
791
+ color: "rgba(0, 0, 0, 0.6)",
792
+ opacity: 0.3,
793
+ blur: 5
794
+ },
795
+ }, {
796
+ text: "#3",
797
+ x: 475,
798
+ y: 297,
799
+ fontSize: 32,
800
+ fontName: 'LevelFont eng',
801
+ fontPath: './levelFont.ttf',
802
+ color: '#cd7f32',
803
+ stroke: {
804
+ color: 'black',
805
+ width: 0.6,
806
+ },
807
+ shadow: {
808
+ offsetX: 3,
809
+ offsetY: 3,
810
+ color: "rgba(0, 0, 0, 0.6)",
811
+ opacity: 0.3,
812
+ blur: 5
813
+ },
814
+ }, {
815
+ text: "#4",
816
+ x: 475,
817
+ y: 275 + 92,
818
+ fontSize: 32,
819
+ fontName: 'LevelFont eng',
820
+ fontPath: './levelFont.ttf',
821
+ color: 'white',
822
+ stroke: {
823
+ color: 'black',
824
+ width: 0.6,
825
+ },
826
+ shadow: {
827
+ offsetX: 3,
828
+ offsetY: 3,
829
+ color: "rgba(0, 0, 0, 0.6)",
830
+ opacity: 0.3,
831
+ blur: 5
832
+ },
833
+ }, {
834
+ text: "#5",
835
+ x: 475,
836
+ y: 275 + 75 + 87,
837
+ fontSize: 32,
838
+ fontName: 'LevelFont eng',
839
+ fontPath: './levelFont.ttf',
840
+ color: 'white',
841
+ stroke: {
842
+ color: 'black',
843
+ width: 0.6,
844
+ },
845
+ shadow: {
846
+ offsetX: 3,
847
+ offsetY: 3,
848
+ color: "rgba(0, 0, 0, 0.6)",
849
+ opacity: 0.3,
850
+ blur: 5
851
+ },
852
+ });
853
+ _a.label = 18;
854
+ case 18:
855
+ _i++;
856
+ return [3 /*break*/, 12];
857
+ case 19: return [4 /*yield*/, painter.drawImages(images, canvasOptions)];
858
+ case 20:
859
+ image = _a.sent();
860
+ return [4 /*yield*/, painter.addText(textOptionsArray, image, __dirname)];
861
+ case 21:
862
+ card = _a.sent();
863
+ resizeOptions = {
864
+ imagePath: card,
865
+ size: { width: 1200, height: 1200 },
866
+ };
867
+ return [4 /*yield*/, painter.resize(resizeOptions)];
868
+ case 22:
869
+ resizedImageBuffer = _a.sent();
870
+ return [2 /*return*/, resizedImageBuffer];
871
+ case 23: return [2 /*return*/];
872
+ }
873
+ });
595
874
  });
596
-
597
- textOptionsArray.push(
598
- {
599
- text: `SERVER LEADERBOARD`,
600
- x: 55,
601
- y: 16,
602
- fontSize: 55,
603
- fontName: 'LevelFont eng',
604
- fontPath: './levelFont.ttf',
605
- color: '#14cee7',
606
- stroke: {
607
- color: 'black',
608
- width: 0.5,
609
- },
610
- shadow: {
611
- offsetX: 3,
612
- offsetY: 3,
613
- color: "rgba(0, 0, 0, 0.8)",
614
- opacity: 0.4,
615
- blur: 5
616
- },
617
- },
618
- {
619
- text: `pfp`,
620
- x: 52,
621
- y: 87,
622
- fontSize: 25,
623
- fontName: 'LevelFont eng',
624
- fontPath: './levelFont.ttf',
625
- color: 'white',
626
- stroke: {
627
- color: 'black',
628
- width: 0.5,
629
- },
630
- },
631
- {
632
- text: `USERNAME`,
633
- x: 185,
634
- y: 87,
635
- fontSize: 30,
636
- fontName: 'LevelFont eng',
637
- fontPath: './levelFont.ttf',
638
- color: 'white',
639
- stroke: {
640
- color: 'black',
641
- width: 0.5,
642
- },
643
- },
644
- {
645
- text: `LEVEL`,
646
- x: 395,
647
- y: 92,
648
- fontSize: 25,
649
- fontName: 'LevelFont eng',
650
- fontPath: './levelFont.ttf',
651
- color: 'white',
652
- stroke: {
653
- color: 'black',
654
- width: 0.5,
655
- },
656
- },
657
- {
658
- text: `RANK`,
659
- x: 472,
660
- y: 92,
661
- fontSize: 25,
662
- fontName: 'LevelFont eng',
663
- fontPath: './levelFont.ttf',
664
- color: 'white',
665
- stroke: {
666
- color: 'black',
667
- width: 0.5,
668
- },
669
- },
670
- {
671
- text: `${user.username.slice(0, 9).trim()}`,
672
- x: 145,
673
- y: 83 + (32 + 38) * images.length,
674
- fontSize: fontSize + 6,
675
- fontName: fontName,
676
- fontPath: fontPath,
677
- color: colorText,
678
- stroke: {
679
- color: 'black',
680
- width: 0.5,
681
- },
682
- shadow: {
683
- offsetX: 3,
684
- offsetY: 3,
685
- color: "rgba(0, 0, 0, 0.8)",
686
- opacity: 0.4,
687
- blur: 5
688
- },
689
- },
690
- {
691
- text: `${user.level}`,
692
- x: dynamicLevel(user.level),
693
- y: 85 + (32 + 38) * images.length,
694
- fontSize: 35,
695
- fontName: 'LevelFont eng',
696
- fontPath: './levelFont.ttf',
697
- color: colorText,
698
- stroke: {
699
- color: 'black',
700
- width: 0.5,
701
- },
702
- shadow: {
703
- offsetX: 3,
704
- offsetY: 3,
705
- color: "rgba(0, 0, 0, 0.8)",
706
- opacity: 0.3,
707
- blur: 5
708
- },
709
- },
710
- {
711
- text: `#1`,
712
- x: 475,
713
- y: 157,
714
- fontSize: 32,
715
- fontName: 'LevelFont eng',
716
- fontPath: './levelFont.ttf',
717
- color: '#ffd700',
718
- stroke: {
719
- color: 'black',
720
- width: 0.6,
721
- },
722
- shadow: {
723
- offsetX: 3,
724
- offsetY: 3,
725
- color: "rgba(0, 0, 0, 0.6)",
726
- opacity: 0.3,
727
- blur: 5
728
- },
729
- },
730
- {
731
- text: `#2`,
732
- x: 475,
733
- y: 225,
734
- fontSize: 32,
735
- fontName: 'LevelFont eng',
736
- fontPath: './levelFont.ttf',
737
- color: '#bababa',
738
- stroke: {
739
- color: 'black',
740
- width: 0.4,
741
- },
742
- shadow: {
743
- offsetX: 3,
744
- offsetY: 3,
745
- color: "rgba(0, 0, 0, 0.6)",
746
- opacity: 0.3,
747
- blur: 5
748
- },
749
- },
750
- {
751
- text: `#3`,
752
- x: 475,
753
- y: 297,
754
- fontSize: 32,
755
- fontName: 'LevelFont eng',
756
- fontPath: './levelFont.ttf',
757
- color: '#cd7f32',
758
- stroke: {
759
- color: 'black',
760
- width: 0.6,
761
- },
762
- shadow: {
763
- offsetX: 3,
764
- offsetY: 3,
765
- color: "rgba(0, 0, 0, 0.6)",
766
- opacity: 0.3,
767
- blur: 5
768
- },
769
- },
770
- {
771
- text: `#4`,
772
- x: 475,
773
- y: 275 + 92,
774
- fontSize: 32,
775
- fontName: 'LevelFont eng',
776
- fontPath: './levelFont.ttf',
777
- color: 'white',
778
- stroke: {
779
- color: 'black',
780
- width: 0.6,
781
- },
782
- shadow: {
783
- offsetX: 3,
784
- offsetY: 3,
785
- color: "rgba(0, 0, 0, 0.6)",
786
- opacity: 0.3,
787
- blur: 5
788
- },
789
- },
790
- {
791
- text: `#5`,
792
- x: 475,
793
- y: 275 + 75 + 87,
794
- fontSize: 32,
795
- fontName: 'LevelFont eng',
796
- fontPath: './levelFont.ttf',
797
- color: 'white',
798
- stroke: {
799
- color: 'black',
800
- width: 0.6,
801
- },
802
- shadow: {
803
- offsetX: 3,
804
- offsetY: 3,
805
- color: "rgba(0, 0, 0, 0.6)",
806
- opacity: 0.3,
807
- blur: 5
808
- },
809
- }
810
- );
811
- }
812
-
813
- const image = await painter.drawImages(images, canvasOptions);
814
-
815
- const card = await painter.addText(textOptionsArray, image, __dirname);
816
-
817
- const resizeOptions = {
818
- imagePath: card,
819
- size: { width: 1200, height: 1200 },
820
- };
821
-
822
- const resizedImageBuffer = await painter.resize(resizeOptions);
823
-
824
- return resizedImageBuffer;
825
- }
826
875
  }
827
-
828
- function randomHex() {
829
- const letters = "0123456789ABCDEF";
830
- let color = "#";
831
-
832
- for (let i = 0; i < 6; i++) {
876
+ exports.leaderBoard = leaderBoard;
877
+ function randomHex() {
878
+ var letters = "0123456789ABCDEF";
879
+ var color = "#";
880
+ for (var i = 0; i < 6; i++) {
833
881
  color += letters[Math.floor(Math.random() * 16)];
834
- }
835
-
836
- return color;
837
- }
838
-
839
-
840
- module.exports = { levelCard, leaderBoard, xpRank };
882
+ }
883
+ return color;
884
+ }