apexify.js 2.4.4-beta.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +4 -710
  2. package/dataSQL/data.sql +5 -0
  3. package/dataSQL/dataName.sql +0 -0
  4. package/dataSQL/example_table.sql +1 -0
  5. package/index.js +3 -78
  6. package/lib/ai/apexAI.js +2 -2
  7. package/lib/{discord/events/handler → ai/buttons}/tools.js +1 -1
  8. package/lib/utils.js +2 -72
  9. package/package.json +2 -82
  10. package/lib/canvas/themes/level ara.ttf +0 -0
  11. package/lib/canvas/themes/levelFont.ttf +0 -0
  12. package/lib/canvas/themes/levels-card.js +0 -884
  13. package/lib/canvas/themes/music-card.js +0 -342
  14. package/lib/canvas/themes/numbers.ttf +0 -0
  15. package/lib/canvas/themes/tajawal.ttf +0 -0
  16. package/lib/database/MongoDB.js +0 -126
  17. package/lib/database/NanoDB.js +0 -1341
  18. package/lib/database/mongoDb/aggregate.js +0 -120
  19. package/lib/database/mongoDb/countDocs.js +0 -115
  20. package/lib/database/mongoDb/createCollection.js +0 -125
  21. package/lib/database/mongoDb/dataSize.js +0 -89
  22. package/lib/database/mongoDb/distinct.js +0 -110
  23. package/lib/database/mongoDb/drop.js +0 -76
  24. package/lib/database/mongoDb/find.js +0 -122
  25. package/lib/database/mongoDb/geoNear.js +0 -91
  26. package/lib/database/mongoDb/index.js +0 -71
  27. package/lib/database/mongoDb/listCollections.js +0 -81
  28. package/lib/database/mongoDb/migrateAndPrune.js +0 -89
  29. package/lib/database/mongoDb/migrateData.js +0 -79
  30. package/lib/database/mongoDb/remove.js +0 -73
  31. package/lib/database/mongoDb/removeMany.js +0 -73
  32. package/lib/database/mongoDb/removeManyExcept.js +0 -91
  33. package/lib/database/mongoDb/removeSpecific.js +0 -93
  34. package/lib/database/mongoDb/save.js +0 -94
  35. package/lib/database/mongoDb/searchMany.js +0 -109
  36. package/lib/database/mongoDb/textSearch.js +0 -88
  37. package/lib/database/mongoDb/updateAll.js +0 -80
  38. package/lib/database/mongoDb/updateAllExcept.js +0 -108
  39. package/lib/database/mongoDb/updateData.js +0 -106
  40. package/lib/database/nanoDb/fetchData.js +0 -39
  41. package/lib/database/nanoDb/removeField.js +0 -46
  42. package/lib/database/nanoDb/saveData.js +0 -68
  43. package/lib/database/nanoDb/updateFilter.js +0 -24
  44. package/lib/database/ready-schemas.js +0 -245
  45. package/lib/database/utils.js +0 -62
  46. package/lib/discord/discord-build/commands-(prefix)/music/functions/buttons.js +0 -361
  47. package/lib/discord/discord-build/commands-(prefix)/music/functions/end.js +0 -58
  48. package/lib/discord/discord-build/commands-(prefix)/music/functions/start.js +0 -115
  49. package/lib/discord/discord-build/commands-(prefix)/music/play.js +0 -152
  50. package/lib/discord/discord-build/commands-(prefix)/music/previous.js +0 -82
  51. package/lib/discord/discord-build/commands-(prefix)/music/resume.js +0 -93
  52. package/lib/discord/discord-build/commands-(prefix)/music/skip.js +0 -82
  53. package/lib/discord/discord-build/commands-(prefix)/music/stop.js +0 -79
  54. package/lib/discord/discord-build/components/buttons.js +0 -75
  55. package/lib/discord/discord-build/components/menus.js +0 -81
  56. package/lib/discord/discord-build/components/paginator.js +0 -156
  57. package/lib/discord/discord-build/components/permsChecker.js +0 -81
  58. package/lib/discord/discord-build/levelingSystem/cLevel.js +0 -829
  59. package/lib/discord/discord-build/levelingSystem/cLevelsArray.json +0 -104
  60. package/lib/discord/discord-build/utils.js +0 -23
  61. package/lib/discord/events/eventer.js +0 -145
  62. package/lib/discord/events/prefixRegister.js +0 -148
  63. package/lib/discord/events/prefixResponder.js +0 -163
  64. package/lib/discord/events/slashRegister.js +0 -183
  65. package/lib/discord/events/slashResponder.js +0 -108
  66. package/lib/discord/events/starter.js +0 -441
  67. package/lib/discord/functions/perms.js +0 -19
  68. package/lib/discord/utils.js +0 -6
  69. package/lib/general-functions/discord/typeWriter.js +0 -77
  70. package/lib/general-functions/utils.js +0 -19
  71. /package/lib/{discord/events/handler → ai/buttons}/drawMenu.js +0 -0
@@ -1,884 +0,0 @@
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
- });
10
- };
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 };
36
- }
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
- });
134
- }
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
- });
424
- }
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
- });
874
- });
875
- }
876
- exports.leaderBoard = leaderBoard;
877
- function randomHex() {
878
- var letters = "0123456789ABCDEF";
879
- var color = "#";
880
- for (var i = 0; i < 6; i++) {
881
- color += letters[Math.floor(Math.random() * 16)];
882
- }
883
- return color;
884
- }