apexify.js 1.2.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.
Files changed (75) hide show
  1. package/README.md +1117 -0
  2. package/index.js +111 -0
  3. package/lib/ai/apexAI.js +312 -0
  4. package/lib/ai/functions/chunkString.js +8 -0
  5. package/lib/ai/functions/draw.js +347 -0
  6. package/lib/ai/functions/generateVoiceResponse.js +239 -0
  7. package/lib/ai/functions/processImageAttachments.js +93 -0
  8. package/lib/ai/functions/processMessageContent.js +48 -0
  9. package/lib/ai/functions/readFiles.js +95 -0
  10. package/lib/ai/functions/shouldDrawImage.js +12 -0
  11. package/lib/ai/utils.js +18 -0
  12. package/lib/canvas/ApexPainter.js +1194 -0
  13. package/lib/canvas/themes/level ara.ttf +0 -0
  14. package/lib/canvas/themes/levelFont.ttf +0 -0
  15. package/lib/canvas/themes/levels-card.js +872 -0
  16. package/lib/canvas/themes/music-card.js +342 -0
  17. package/lib/canvas/themes/numbers.ttf +0 -0
  18. package/lib/canvas/themes/tajawal.ttf +0 -0
  19. package/lib/database/MongoDB.js +126 -0
  20. package/lib/database/NanoDB.js +1318 -0
  21. package/lib/database/mongoDb/aggregate.js +120 -0
  22. package/lib/database/mongoDb/countDocs.js +115 -0
  23. package/lib/database/mongoDb/createCollection.js +125 -0
  24. package/lib/database/mongoDb/dataSize.js +89 -0
  25. package/lib/database/mongoDb/distinct.js +110 -0
  26. package/lib/database/mongoDb/drop.js +76 -0
  27. package/lib/database/mongoDb/find.js +122 -0
  28. package/lib/database/mongoDb/geoNear.js +91 -0
  29. package/lib/database/mongoDb/index.js +71 -0
  30. package/lib/database/mongoDb/listCollections.js +81 -0
  31. package/lib/database/mongoDb/migrateAndPrune.js +89 -0
  32. package/lib/database/mongoDb/migrateData.js +79 -0
  33. package/lib/database/mongoDb/remove.js +73 -0
  34. package/lib/database/mongoDb/removeMany.js +73 -0
  35. package/lib/database/mongoDb/removeManyExcept.js +91 -0
  36. package/lib/database/mongoDb/removeSpecific.js +93 -0
  37. package/lib/database/mongoDb/save.js +94 -0
  38. package/lib/database/mongoDb/searchMany.js +109 -0
  39. package/lib/database/mongoDb/textSearch.js +88 -0
  40. package/lib/database/mongoDb/updateAll.js +80 -0
  41. package/lib/database/mongoDb/updateAllExcept.js +108 -0
  42. package/lib/database/mongoDb/updateData.js +106 -0
  43. package/lib/database/nanoDb/fetchData.js +39 -0
  44. package/lib/database/nanoDb/removeField.js +46 -0
  45. package/lib/database/nanoDb/saveData.js +68 -0
  46. package/lib/database/nanoDb/updateFilter.js +24 -0
  47. package/lib/database/ready-schemas.js +245 -0
  48. package/lib/database/utils.js +58 -0
  49. package/lib/discord/discord-build/commands-(prefix)/music/functions/buttons.js +361 -0
  50. package/lib/discord/discord-build/commands-(prefix)/music/functions/end.js +58 -0
  51. package/lib/discord/discord-build/commands-(prefix)/music/functions/start.js +115 -0
  52. package/lib/discord/discord-build/commands-(prefix)/music/play.js +152 -0
  53. package/lib/discord/discord-build/commands-(prefix)/music/previous.js +82 -0
  54. package/lib/discord/discord-build/commands-(prefix)/music/resume.js +93 -0
  55. package/lib/discord/discord-build/commands-(prefix)/music/skip.js +82 -0
  56. package/lib/discord/discord-build/commands-(prefix)/music/stop.js +79 -0
  57. package/lib/discord/discord-build/components/buttons.js +75 -0
  58. package/lib/discord/discord-build/components/menus.js +81 -0
  59. package/lib/discord/discord-build/components/paginator.js +156 -0
  60. package/lib/discord/discord-build/components/permsChecker.js +81 -0
  61. package/lib/discord/discord-build/utils.js +21 -0
  62. package/lib/discord/events/eventer.js +100 -0
  63. package/lib/discord/events/handler/drawMenu.js +351 -0
  64. package/lib/discord/events/handler/tools.js +652 -0
  65. package/lib/discord/events/prefixRegister.js +136 -0
  66. package/lib/discord/events/prefixResponder.js +163 -0
  67. package/lib/discord/events/slashRegister.js +199 -0
  68. package/lib/discord/events/slashResponder.js +108 -0
  69. package/lib/discord/events/starter.js +335 -0
  70. package/lib/discord/functions/perms.js +19 -0
  71. package/lib/discord/utils.js +6 -0
  72. package/lib/general-functions/discord/type-writer.js +77 -0
  73. package/lib/general-functions/utils.js +0 -0
  74. package/lib/utils.js +90 -0
  75. package/package.json +118 -0
@@ -0,0 +1,652 @@
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.filters = void 0;
40
+ var apexPainter_1 = require("../../../canvas/ApexPainter");
41
+ var apexPainter = new apexPainter_1.ApexPainter();
42
+ function filters(client) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var _this = this;
45
+ return __generator(this, function (_a) {
46
+ client.on("interactionCreate", function (z) { return __awaiter(_this, void 0, void 0, function () {
47
+ var submitId, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, width, height, resizedBuffer, error_1, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, hexColor, filteredBuffer, error_2, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, imageType, convertedBuffer, error_3, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, brightnessDegree, processedBuffer, error_4, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, processedBuffer, error_5, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, xy, wh, size, xyArray, whArray, x, y, width, height, processedBuffer, error_6, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, blurRadius, processedBuffer, error_7, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, fadeFactor, processedBuffer, error_8, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, processedBuffer, error_9, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, processedBuffer, error_10, imagePosition, interactionMessage, attachmentsArray, totalAttachments, selectedAttachment, imageURL, contrastValue, processedBuffer, error_11;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0:
51
+ if (!z.isModalSubmit())
52
+ return [2 /*return*/];
53
+ submitId = z.customId;
54
+ if (!(submitId === "resizing_image_zenithmodal")) return [3 /*break*/, 12];
55
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
56
+ case 1:
57
+ _a.sent();
58
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
59
+ return [4 /*yield*/, z.message.fetch()];
60
+ case 2:
61
+ interactionMessage = _a.sent();
62
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
63
+ totalAttachments = attachmentsArray.length;
64
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 9];
65
+ selectedAttachment = attachmentsArray[imagePosition - 1];
66
+ imageURL = selectedAttachment.url;
67
+ width = z.fields.getTextInputValue("modal_resizingImage_width");
68
+ height = z.fields.getTextInputValue("modal_resizingImage_height");
69
+ _a.label = 3;
70
+ case 3:
71
+ _a.trys.push([3, 6, , 8]);
72
+ return [4 /*yield*/, apexPainter.resize({
73
+ imagePath: imageURL,
74
+ size: { width: parseInt(width, 10), height: parseInt(height, 10) },
75
+ })];
76
+ case 4:
77
+ resizedBuffer = _a.sent();
78
+ return [4 /*yield*/, z.editReply({
79
+ content: "Resized Image:",
80
+ files: [resizedBuffer],
81
+ ephemeral: true,
82
+ })];
83
+ case 5:
84
+ _a.sent();
85
+ return [3 /*break*/, 8];
86
+ case 6:
87
+ error_1 = _a.sent();
88
+ console.error("Error resizing image:", error_1);
89
+ return [4 /*yield*/, z.editReply({
90
+ content: "Failed to resize image",
91
+ ephemeral: true,
92
+ })];
93
+ case 7:
94
+ _a.sent();
95
+ return [3 /*break*/, 8];
96
+ case 8: return [3 /*break*/, 11];
97
+ case 9: return [4 /*yield*/, z.editReply({
98
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
99
+ ephemeral: true,
100
+ })];
101
+ case 10:
102
+ _a.sent();
103
+ _a.label = 11;
104
+ case 11: return [3 /*break*/, 136];
105
+ case 12:
106
+ if (!(submitId === "Color_Filters")) return [3 /*break*/, 25];
107
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
108
+ case 13:
109
+ _a.sent();
110
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
111
+ return [4 /*yield*/, z.message.fetch()];
112
+ case 14:
113
+ interactionMessage = _a.sent();
114
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
115
+ totalAttachments = attachmentsArray.length;
116
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 22];
117
+ selectedAttachment = attachmentsArray[imagePosition - 1];
118
+ imageURL = selectedAttachment.url;
119
+ hexColor = z.fields.getTextInputValue("color_filter_image");
120
+ return [4 /*yield*/, apexPainter.validateColor(hexColor)];
121
+ case 15:
122
+ _a.sent();
123
+ _a.label = 16;
124
+ case 16:
125
+ _a.trys.push([16, 19, , 21]);
126
+ return [4 /*yield*/, apexPainter.colorFilters(imageURL, hexColor)];
127
+ case 17:
128
+ filteredBuffer = _a.sent();
129
+ return [4 /*yield*/, z.editReply({
130
+ content: "Filtered Image:",
131
+ files: [filteredBuffer],
132
+ ephemeral: true,
133
+ })];
134
+ case 18:
135
+ _a.sent();
136
+ return [3 /*break*/, 21];
137
+ case 19:
138
+ error_2 = _a.sent();
139
+ console.error("Error applying color filter:", error_2);
140
+ return [4 /*yield*/, z.editReply({
141
+ content: "Failed to apply color filter. Note: colors need to be in hex code format.",
142
+ ephemeral: true,
143
+ })];
144
+ case 20:
145
+ _a.sent();
146
+ return [3 /*break*/, 21];
147
+ case 21: return [3 /*break*/, 24];
148
+ case 22: return [4 /*yield*/, z.editReply({
149
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
150
+ ephemeral: true,
151
+ })];
152
+ case 23:
153
+ _a.sent();
154
+ _a.label = 24;
155
+ case 24: return [3 /*break*/, 136];
156
+ case 25:
157
+ if (!(submitId === "Convert_Image_Extension")) return [3 /*break*/, 37];
158
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
159
+ case 26:
160
+ _a.sent();
161
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
162
+ return [4 /*yield*/, z.message.fetch()];
163
+ case 27:
164
+ interactionMessage = _a.sent();
165
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
166
+ totalAttachments = attachmentsArray.length;
167
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 34];
168
+ selectedAttachment = attachmentsArray[imagePosition - 1];
169
+ imageURL = selectedAttachment.url;
170
+ imageType = z.fields.getTextInputValue("image_type");
171
+ _a.label = 28;
172
+ case 28:
173
+ _a.trys.push([28, 31, , 33]);
174
+ return [4 /*yield*/, apexPainter.imageConverter(imageURL, imageType, __dirname)];
175
+ case 29:
176
+ convertedBuffer = _a.sent();
177
+ return [4 /*yield*/, z.editReply({
178
+ content: "Converted Image:",
179
+ files: [convertedBuffer],
180
+ ephemeral: true,
181
+ })];
182
+ case 30:
183
+ _a.sent();
184
+ return [3 /*break*/, 33];
185
+ case 31:
186
+ error_3 = _a.sent();
187
+ console.error("Error converting image extension:", error_3);
188
+ return [4 /*yield*/, z.editReply({
189
+ content: "Failed to convert image extension",
190
+ ephemeral: true,
191
+ })];
192
+ case 32:
193
+ _a.sent();
194
+ return [3 /*break*/, 33];
195
+ case 33: return [3 /*break*/, 36];
196
+ case 34: return [4 /*yield*/, z.editReply({
197
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
198
+ ephemeral: true,
199
+ })];
200
+ case 35:
201
+ _a.sent();
202
+ _a.label = 36;
203
+ case 36: return [3 /*break*/, 136];
204
+ case 37:
205
+ if (!(submitId === "Image_Brightness")) return [3 /*break*/, 50];
206
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
207
+ case 38:
208
+ _a.sent();
209
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
210
+ return [4 /*yield*/, z.message.fetch()];
211
+ case 39:
212
+ interactionMessage = _a.sent();
213
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
214
+ totalAttachments = attachmentsArray.length;
215
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 47];
216
+ selectedAttachment = attachmentsArray[imagePosition - 1];
217
+ imageURL = selectedAttachment.url;
218
+ brightnessDegree = z.fields.getTextInputValue("brightness_degree");
219
+ if (!(brightnessDegree < 0 || brightnessDegree > 1)) return [3 /*break*/, 41];
220
+ return [4 /*yield*/, z.editReply({
221
+ content: "Value must be between 0-1",
222
+ ephemeral: true,
223
+ })];
224
+ case 40: return [2 /*return*/, _a.sent()];
225
+ case 41:
226
+ _a.trys.push([41, 44, , 46]);
227
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
228
+ { type: "brightness", value: parseFloat(brightnessDegree) },
229
+ ])];
230
+ case 42:
231
+ processedBuffer = _a.sent();
232
+ return [4 /*yield*/, z.editReply({
233
+ content: "Brightness Adjusted Image:",
234
+ files: [processedBuffer],
235
+ ephemeral: true,
236
+ })];
237
+ case 43:
238
+ _a.sent();
239
+ return [3 /*break*/, 46];
240
+ case 44:
241
+ error_4 = _a.sent();
242
+ console.error("Error adjusting image brightness:", error_4);
243
+ return [4 /*yield*/, z.editReply({
244
+ content: "Failed to adjust image brightness",
245
+ ephemeral: true,
246
+ })];
247
+ case 45:
248
+ _a.sent();
249
+ return [3 /*break*/, 46];
250
+ case 46: return [3 /*break*/, 49];
251
+ case 47: return [4 /*yield*/, z.editReply({
252
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
253
+ ephemeral: true,
254
+ })];
255
+ case 48:
256
+ _a.sent();
257
+ _a.label = 49;
258
+ case 49: return [3 /*break*/, 136];
259
+ case 50:
260
+ if (!(submitId === "Sepia_Filter")) return [3 /*break*/, 62];
261
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
262
+ case 51:
263
+ _a.sent();
264
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
265
+ return [4 /*yield*/, z.message.fetch()];
266
+ case 52:
267
+ interactionMessage = _a.sent();
268
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
269
+ totalAttachments = attachmentsArray.length;
270
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 59];
271
+ selectedAttachment = attachmentsArray[imagePosition - 1];
272
+ imageURL = selectedAttachment.url;
273
+ _a.label = 53;
274
+ case 53:
275
+ _a.trys.push([53, 56, , 58]);
276
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
277
+ { type: "sepia" },
278
+ ])];
279
+ case 54:
280
+ processedBuffer = _a.sent();
281
+ return [4 /*yield*/, z.editReply({
282
+ content: "Applied Sepia Image:",
283
+ files: [processedBuffer],
284
+ ephemeral: true,
285
+ })];
286
+ case 55:
287
+ _a.sent();
288
+ return [3 /*break*/, 58];
289
+ case 56:
290
+ error_5 = _a.sent();
291
+ console.error("Error applying sepia:", error_5);
292
+ return [4 /*yield*/, z.editReply({
293
+ content: "Failed to apply sepia filter",
294
+ ephemeral: true,
295
+ })];
296
+ case 57:
297
+ _a.sent();
298
+ return [3 /*break*/, 58];
299
+ case 58: return [3 /*break*/, 61];
300
+ case 59: return [4 /*yield*/, z.editReply({
301
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
302
+ ephemeral: true,
303
+ })];
304
+ case 60:
305
+ _a.sent();
306
+ _a.label = 61;
307
+ case 61: return [3 /*break*/, 136];
308
+ case 62:
309
+ if (!(submitId === "Pixelate_Filter")) return [3 /*break*/, 74];
310
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
311
+ case 63:
312
+ _a.sent();
313
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
314
+ return [4 /*yield*/, z.message.fetch()];
315
+ case 64:
316
+ interactionMessage = _a.sent();
317
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
318
+ totalAttachments = attachmentsArray.length;
319
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 71];
320
+ selectedAttachment = attachmentsArray[imagePosition - 1];
321
+ imageURL = selectedAttachment.url;
322
+ xy = z.fields.getTextInputValue("Pixelate_XY");
323
+ wh = z.fields.getTextInputValue("Pixelate_WH");
324
+ size = z.fields.getTextInputValue("Pixelate_Size");
325
+ _a.label = 65;
326
+ case 65:
327
+ _a.trys.push([65, 68, , 70]);
328
+ xyArray = xy
329
+ .split(",")
330
+ .map(function (coord) { return parseInt(coord.trim(), 10); });
331
+ whArray = wh
332
+ .split(",")
333
+ .map(function (coord) { return parseInt(coord.trim(), 10); });
334
+ if (xyArray.length !== 2 ||
335
+ whArray.length !== 2 ||
336
+ xyArray.some(isNaN) ||
337
+ whArray.some(isNaN)) {
338
+ throw new Error('Invalid format for xy or wh. Use the format "x, y" and "width, height" with valid integer values.');
339
+ }
340
+ x = xyArray[0], y = xyArray[1];
341
+ width = whArray[0], height = whArray[1];
342
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
343
+ {
344
+ type: "pixelate",
345
+ size: parseInt(size, 10),
346
+ x: x,
347
+ y: y,
348
+ w: width,
349
+ h: height,
350
+ },
351
+ ])];
352
+ case 66:
353
+ processedBuffer = _a.sent();
354
+ return [4 /*yield*/, z.editReply({
355
+ content: "Pixelated Image:",
356
+ files: [processedBuffer],
357
+ ephemeral: true,
358
+ })];
359
+ case 67:
360
+ _a.sent();
361
+ return [3 /*break*/, 70];
362
+ case 68:
363
+ error_6 = _a.sent();
364
+ console.error("Error applying pixelate filter:", error_6);
365
+ return [4 /*yield*/, z.editReply({
366
+ content: "Failed to apply pixelate filter: " + error_6.message,
367
+ ephemeral: true,
368
+ })];
369
+ case 69:
370
+ _a.sent();
371
+ return [3 /*break*/, 70];
372
+ case 70: return [3 /*break*/, 73];
373
+ case 71: return [4 /*yield*/, z.editReply({
374
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
375
+ ephemeral: true,
376
+ })];
377
+ case 72:
378
+ _a.sent();
379
+ _a.label = 73;
380
+ case 73: return [3 /*break*/, 136];
381
+ case 74:
382
+ if (!(submitId === "Image_Blur")) return [3 /*break*/, 87];
383
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
384
+ case 75:
385
+ _a.sent();
386
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
387
+ return [4 /*yield*/, z.message.fetch()];
388
+ case 76:
389
+ interactionMessage = _a.sent();
390
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
391
+ totalAttachments = attachmentsArray.length;
392
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 84];
393
+ selectedAttachment = attachmentsArray[imagePosition - 1];
394
+ imageURL = selectedAttachment.url;
395
+ blurRadius = z.fields.getTextInputValue("blur_radius");
396
+ if (!(blurRadius < 0 || blurRadius > 100)) return [3 /*break*/, 78];
397
+ return [4 /*yield*/, z.editReply({
398
+ content: "Value must be between 0-100",
399
+ ephemeral: true,
400
+ })];
401
+ case 77: return [2 /*return*/, _a.sent()];
402
+ case 78:
403
+ _a.trys.push([78, 81, , 83]);
404
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
405
+ { type: "blur", radius: parseFloat(blurRadius) },
406
+ ])];
407
+ case 79:
408
+ processedBuffer = _a.sent();
409
+ return [4 /*yield*/, z.editReply({
410
+ content: "Blurred Image:",
411
+ files: [processedBuffer],
412
+ ephemeral: true,
413
+ })];
414
+ case 80:
415
+ _a.sent();
416
+ return [3 /*break*/, 83];
417
+ case 81:
418
+ error_7 = _a.sent();
419
+ console.error("Error applying blur filter:", error_7);
420
+ return [4 /*yield*/, z.editReply({
421
+ content: "Failed to apply blur filter: " + error_7.message,
422
+ ephemeral: true,
423
+ })];
424
+ case 82:
425
+ _a.sent();
426
+ return [3 /*break*/, 83];
427
+ case 83: return [3 /*break*/, 86];
428
+ case 84: return [4 /*yield*/, z.editReply({
429
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
430
+ ephemeral: true,
431
+ })];
432
+ case 85:
433
+ _a.sent();
434
+ _a.label = 86;
435
+ case 86: return [3 /*break*/, 136];
436
+ case 87:
437
+ if (!(submitId === "Image_Fade")) return [3 /*break*/, 100];
438
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
439
+ case 88:
440
+ _a.sent();
441
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
442
+ return [4 /*yield*/, z.message.fetch()];
443
+ case 89:
444
+ interactionMessage = _a.sent();
445
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
446
+ totalAttachments = attachmentsArray.length;
447
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 97];
448
+ selectedAttachment = attachmentsArray[imagePosition - 1];
449
+ imageURL = selectedAttachment.url;
450
+ fadeFactor = z.fields.getTextInputValue("fade_factor");
451
+ if (!(fadeFactor < 0 || fadeFactor > 1)) return [3 /*break*/, 91];
452
+ return [4 /*yield*/, z.editReply({
453
+ content: "Value must be between 0-1",
454
+ ephemeral: true,
455
+ })];
456
+ case 90: return [2 /*return*/, _a.sent()];
457
+ case 91:
458
+ _a.trys.push([91, 94, , 96]);
459
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
460
+ { type: "fade", factor: parseFloat(fadeFactor) },
461
+ ])];
462
+ case 92:
463
+ processedBuffer = _a.sent();
464
+ return [4 /*yield*/, z.editReply({
465
+ content: "Faded Image:",
466
+ files: [processedBuffer],
467
+ ephemeral: true,
468
+ })];
469
+ case 93:
470
+ _a.sent();
471
+ return [3 /*break*/, 96];
472
+ case 94:
473
+ error_8 = _a.sent();
474
+ console.error("Error applying fade filter:", error_8);
475
+ return [4 /*yield*/, z.editReply({
476
+ content: "Failed to apply fade filter: " + error_8.message,
477
+ ephemeral: true,
478
+ })];
479
+ case 95:
480
+ _a.sent();
481
+ return [3 /*break*/, 96];
482
+ case 96: return [3 /*break*/, 99];
483
+ case 97: return [4 /*yield*/, z.editReply({
484
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
485
+ ephemeral: true,
486
+ })];
487
+ case 98:
488
+ _a.sent();
489
+ _a.label = 99;
490
+ case 99: return [3 /*break*/, 136];
491
+ case 100:
492
+ if (!(submitId === "Image_Opaque")) return [3 /*break*/, 112];
493
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
494
+ case 101:
495
+ _a.sent();
496
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
497
+ return [4 /*yield*/, z.message.fetch()];
498
+ case 102:
499
+ interactionMessage = _a.sent();
500
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
501
+ totalAttachments = attachmentsArray.length;
502
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 109];
503
+ selectedAttachment = attachmentsArray[imagePosition - 1];
504
+ imageURL = selectedAttachment.url;
505
+ _a.label = 103;
506
+ case 103:
507
+ _a.trys.push([103, 106, , 108]);
508
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
509
+ { type: "opaque" },
510
+ ])];
511
+ case 104:
512
+ processedBuffer = _a.sent();
513
+ return [4 /*yield*/, z.editReply({
514
+ content: "Opaque Image:",
515
+ files: [processedBuffer],
516
+ ephemeral: true,
517
+ })];
518
+ case 105:
519
+ _a.sent();
520
+ return [3 /*break*/, 108];
521
+ case 106:
522
+ error_9 = _a.sent();
523
+ console.error("Error applying opaque filter:", error_9);
524
+ return [4 /*yield*/, z.editReply({
525
+ content: "Failed to apply opaque filter: " + error_9.message,
526
+ ephemeral: true,
527
+ })];
528
+ case 107:
529
+ _a.sent();
530
+ return [3 /*break*/, 108];
531
+ case 108: return [3 /*break*/, 111];
532
+ case 109: return [4 /*yield*/, z.editReply({
533
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
534
+ ephemeral: true,
535
+ })];
536
+ case 110:
537
+ _a.sent();
538
+ _a.label = 111;
539
+ case 111: return [3 /*break*/, 136];
540
+ case 112:
541
+ if (!(submitId === "Image_GrayScale")) return [3 /*break*/, 124];
542
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
543
+ case 113:
544
+ _a.sent();
545
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
546
+ return [4 /*yield*/, z.message.fetch()];
547
+ case 114:
548
+ interactionMessage = _a.sent();
549
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
550
+ totalAttachments = attachmentsArray.length;
551
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 121];
552
+ selectedAttachment = attachmentsArray[imagePosition - 1];
553
+ imageURL = selectedAttachment.url;
554
+ _a.label = 115;
555
+ case 115:
556
+ _a.trys.push([115, 118, , 120]);
557
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
558
+ { type: "greyscale" },
559
+ ])];
560
+ case 116:
561
+ processedBuffer = _a.sent();
562
+ return [4 /*yield*/, z.editReply({
563
+ content: "Grayscale Image:",
564
+ files: [processedBuffer],
565
+ ephemeral: true,
566
+ })];
567
+ case 117:
568
+ _a.sent();
569
+ return [3 /*break*/, 120];
570
+ case 118:
571
+ error_10 = _a.sent();
572
+ console.error("Error applying grayscale filter:", error_10);
573
+ return [4 /*yield*/, z.editReply({
574
+ content: "Failed to apply grayscale filter: " + error_10.message,
575
+ ephemeral: true,
576
+ })];
577
+ case 119:
578
+ _a.sent();
579
+ return [3 /*break*/, 120];
580
+ case 120: return [3 /*break*/, 123];
581
+ case 121: return [4 /*yield*/, z.editReply({
582
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
583
+ ephemeral: true,
584
+ })];
585
+ case 122:
586
+ _a.sent();
587
+ _a.label = 123;
588
+ case 123: return [3 /*break*/, 136];
589
+ case 124:
590
+ if (!(submitId === "Image_Contrast")) return [3 /*break*/, 136];
591
+ return [4 /*yield*/, z.deferReply({ ephemeral: true })];
592
+ case 125:
593
+ _a.sent();
594
+ imagePosition = parseInt(z.fields.getTextInputValue("Image_Postion"), 10);
595
+ return [4 /*yield*/, z.message.fetch()];
596
+ case 126:
597
+ interactionMessage = _a.sent();
598
+ attachmentsArray = Array.from(interactionMessage.attachments.values());
599
+ totalAttachments = attachmentsArray.length;
600
+ if (!(imagePosition >= 1 && imagePosition <= totalAttachments)) return [3 /*break*/, 134];
601
+ selectedAttachment = attachmentsArray[imagePosition - 1];
602
+ imageURL = selectedAttachment.url;
603
+ contrastValue = z.fields.getTextInputValue("Contrast_Value");
604
+ if (!(contrastValue < 0 || contrastValue > 2)) return [3 /*break*/, 128];
605
+ return [4 /*yield*/, z.editReply({
606
+ content: "Value must be between 0-2",
607
+ ephemeral: true,
608
+ })];
609
+ case 127: return [2 /*return*/, _a.sent()];
610
+ case 128:
611
+ _a.trys.push([128, 131, , 133]);
612
+ return [4 /*yield*/, apexPainter.processImage(imageURL, [
613
+ { type: "contrast", value: parseFloat(contrastValue) },
614
+ ])];
615
+ case 129:
616
+ processedBuffer = _a.sent();
617
+ return [4 /*yield*/, z.editReply({
618
+ content: "Contrasted Image:",
619
+ files: [processedBuffer],
620
+ ephemeral: true,
621
+ })];
622
+ case 130:
623
+ _a.sent();
624
+ return [3 /*break*/, 133];
625
+ case 131:
626
+ error_11 = _a.sent();
627
+ console.error("Error applying contrast filter:", error_11);
628
+ return [4 /*yield*/, z.editReply({
629
+ content: "Failed to apply contrast filter: " + error_11.message,
630
+ ephemeral: true,
631
+ })];
632
+ case 132:
633
+ _a.sent();
634
+ return [3 /*break*/, 133];
635
+ case 133: return [3 /*break*/, 136];
636
+ case 134: return [4 /*yield*/, z.editReply({
637
+ content: "Invalid image position. Please select a position between 1 and ".concat(totalAttachments, "."),
638
+ ephemeral: true,
639
+ })];
640
+ case 135:
641
+ _a.sent();
642
+ _a.label = 136;
643
+ case 136: return [2 /*return*/];
644
+ }
645
+ });
646
+ }); });
647
+ return [2 /*return*/];
648
+ });
649
+ });
650
+ }
651
+
652
+ exports.filters = filters;