apexify.js 2.3.1 → 2.3.2

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