apexify.js 3.1.8 → 3.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.
- package/README.md +1 -1
- package/dist/ai/ApexAI.d.ts.map +1 -1
- package/dist/ai/ApexAI.js +10 -9
- package/dist/ai/ApexAI.js.map +1 -1
- package/dist/ai/buttons/drawMenu.d.ts.map +1 -1
- package/dist/ai/buttons/drawMenu.js +259 -256
- package/dist/ai/buttons/drawMenu.js.map +1 -1
- package/dist/ai/buttons/tools.d.ts.map +1 -1
- package/dist/ai/buttons/tools.js +366 -363
- package/dist/ai/buttons/tools.js.map +1 -1
- package/dist/canvas/ApexPainter.d.ts +7 -5
- package/dist/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/canvas/ApexPainter.js +27 -4
- package/dist/canvas/ApexPainter.js.map +1 -1
- package/dist/canvas/utils/general functions.d.ts +4 -1
- package/dist/canvas/utils/general functions.d.ts.map +1 -1
- package/dist/canvas/utils/general functions.js +132 -19
- package/dist/canvas/utils/general functions.js.map +1 -1
- package/dist/canvas/utils/types.d.ts +17 -0
- package/dist/canvas/utils/types.d.ts.map +1 -1
- package/dist/canvas/utils/utils.d.ts +3 -3
- package/dist/canvas/utils/utils.d.ts.map +1 -1
- package/dist/canvas/utils/utils.js +3 -1
- package/dist/canvas/utils/utils.js.map +1 -1
- package/package.json +10 -1
package/dist/ai/buttons/tools.js
CHANGED
|
@@ -5,437 +5,440 @@ const utils_1 = require("../../utils");
|
|
|
5
5
|
const apexPainter = new utils_1.ApexPainter();
|
|
6
6
|
async function filters(Apex) {
|
|
7
7
|
Apex.on("interactionCreate", async (a) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
try {
|
|
9
|
+
if (!a.isModalSubmit())
|
|
10
|
+
return;
|
|
11
|
+
const submitId = a.customId;
|
|
12
|
+
if (submitId === "resizing_image_zenithmodal") {
|
|
13
|
+
await a.deferReply({ ephemeral: true });
|
|
14
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
15
|
+
const interactionMessage = await a.message.fetch();
|
|
16
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
17
|
+
const totalAttachments = attachmentsArray.length;
|
|
18
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
19
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
20
|
+
const imageURL = selectedAttachment.url;
|
|
21
|
+
const width = a.fields.getTextInputValue("modal_resizingImage_width");
|
|
22
|
+
const height = a.fields.getTextInputValue("modal_resizingImage_height");
|
|
23
|
+
try {
|
|
24
|
+
const resizedBuffer = await apexPainter.resize({
|
|
25
|
+
imagePath: imageURL,
|
|
26
|
+
size: { width: parseInt(width, 10), height: parseInt(height, 10) },
|
|
27
|
+
});
|
|
28
|
+
await a.editReply({
|
|
29
|
+
content: "Resized Image:",
|
|
30
|
+
files: [resizedBuffer],
|
|
31
|
+
ephemeral: true,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error("Error resizing image:", error);
|
|
36
|
+
await a.editReply({
|
|
37
|
+
content: "Failed to resize image",
|
|
38
|
+
ephemeral: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
console.error("Error resizing image:", error);
|
|
42
|
+
else {
|
|
35
43
|
await a.editReply({
|
|
36
|
-
content:
|
|
44
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
37
45
|
ephemeral: true,
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
|
-
else {
|
|
42
|
-
await a.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
else if (submitId === "Color_Filters") {
|
|
50
|
+
await a.deferReply({ ephemeral: true });
|
|
51
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
52
|
+
const interactionMessage = await a.message.fetch();
|
|
53
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
54
|
+
const totalAttachments = attachmentsArray.length;
|
|
55
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
56
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
57
|
+
const imageURL = selectedAttachment.url;
|
|
58
|
+
const hexColor = a.fields.getTextInputValue("color_filter_image");
|
|
59
|
+
apexPainter.validHex(hexColor);
|
|
60
|
+
try {
|
|
61
|
+
const filteredBuffer = await apexPainter.colorsFilter(imageURL, hexColor);
|
|
62
|
+
await a.editReply({
|
|
63
|
+
content: "Filtered Image:",
|
|
64
|
+
files: [filteredBuffer],
|
|
65
|
+
ephemeral: true,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error("Error applying color filter:", error);
|
|
70
|
+
await a.editReply({
|
|
71
|
+
content: "Failed to apply color filter. Note: colors need to be in hex code format.",
|
|
72
|
+
ephemeral: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
console.error("Error applying color filter:", error);
|
|
76
|
+
else {
|
|
69
77
|
await a.editReply({
|
|
70
|
-
content:
|
|
78
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
71
79
|
ephemeral: true,
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
|
-
else {
|
|
76
|
-
await a.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
else if (submitId === "Convert_Image_Extension") {
|
|
84
|
+
await a.deferReply({ ephemeral: true });
|
|
85
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
86
|
+
const interactionMessage = await a.message.fetch();
|
|
87
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
88
|
+
const totalAttachments = attachmentsArray.length;
|
|
89
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
90
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
91
|
+
const imageURL = selectedAttachment.url;
|
|
92
|
+
const imageType = a.fields.getTextInputValue("image_type");
|
|
93
|
+
try {
|
|
94
|
+
const convertedBuffer = await apexPainter.imgconverter(imageURL, imageType, __dirname);
|
|
95
|
+
await a.editReply({
|
|
96
|
+
content: "Converted Image:",
|
|
97
|
+
files: [convertedBuffer],
|
|
98
|
+
ephemeral: true,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error("Error converting image extension:", error);
|
|
103
|
+
await a.editReply({
|
|
104
|
+
content: "Failed to convert image extension",
|
|
105
|
+
ephemeral: true,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
console.error("Error converting image extension:", error);
|
|
109
|
+
else {
|
|
102
110
|
await a.editReply({
|
|
103
|
-
content:
|
|
111
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
104
112
|
ephemeral: true,
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
|
-
else {
|
|
109
|
-
await a.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
116
|
+
else if (submitId === "Image_Brightness") {
|
|
117
|
+
await a.deferReply({ ephemeral: true });
|
|
118
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
119
|
+
const interactionMessage = await a.message.fetch();
|
|
120
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
121
|
+
const totalAttachments = attachmentsArray.length;
|
|
122
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
123
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
124
|
+
const imageURL = selectedAttachment.url;
|
|
125
|
+
const brightnessDegree = a.fields.getTextInputValue("brightness_degree");
|
|
126
|
+
if (brightnessDegree < 0 || brightnessDegree > 1) {
|
|
127
|
+
return await a.editReply({
|
|
128
|
+
content: "Value must be between 0-1",
|
|
129
|
+
ephemeral: true,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
134
|
+
{ type: "brightness", value: parseFloat(brightnessDegree) },
|
|
135
|
+
]);
|
|
136
|
+
await a.editReply({
|
|
137
|
+
content: "Brightness Adjusted Image:",
|
|
138
|
+
files: [processedBuffer],
|
|
139
|
+
ephemeral: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error("Error adjusting image brightness:", error);
|
|
144
|
+
await a.editReply({
|
|
145
|
+
content: "Failed to adjust image brightness",
|
|
146
|
+
ephemeral: true,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
140
149
|
}
|
|
141
|
-
|
|
142
|
-
console.error("Error adjusting image brightness:", error);
|
|
150
|
+
else {
|
|
143
151
|
await a.editReply({
|
|
144
|
-
content:
|
|
152
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
145
153
|
ephemeral: true,
|
|
146
154
|
});
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
|
-
else {
|
|
150
|
-
await a.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
else if (submitId === "Sepia_Filter") {
|
|
158
|
+
await a.deferReply({ ephemeral: true });
|
|
159
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
160
|
+
const interactionMessage = await a.message.fetch();
|
|
161
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
162
|
+
const totalAttachments = attachmentsArray.length;
|
|
163
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
164
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
165
|
+
const imageURL = selectedAttachment.url;
|
|
166
|
+
try {
|
|
167
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
168
|
+
{ type: "sepia" },
|
|
169
|
+
]);
|
|
170
|
+
await a.editReply({
|
|
171
|
+
content: "Applied Sepia Image:",
|
|
172
|
+
files: [processedBuffer],
|
|
173
|
+
ephemeral: true,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error("Error applying sepia:", error);
|
|
178
|
+
await a.editReply({
|
|
179
|
+
content: "Failed to apply sepia filter",
|
|
180
|
+
ephemeral: true,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
174
183
|
}
|
|
175
|
-
|
|
176
|
-
console.error("Error applying sepia:", error);
|
|
184
|
+
else {
|
|
177
185
|
await a.editReply({
|
|
178
|
-
content:
|
|
186
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
179
187
|
ephemeral: true,
|
|
180
188
|
});
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
else {
|
|
184
|
-
await a.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
191
|
+
else if (submitId === "Pixelate_Filter") {
|
|
192
|
+
await a.deferReply({ ephemeral: true });
|
|
193
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
194
|
+
const interactionMessage = await a.message.fetch();
|
|
195
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
196
|
+
const totalAttachments = attachmentsArray.length;
|
|
197
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
198
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
199
|
+
const imageURL = selectedAttachment.url;
|
|
200
|
+
const xy = a.fields.getTextInputValue("Pixelate_XY");
|
|
201
|
+
const wh = a.fields.getTextInputValue("Pixelate_WH");
|
|
202
|
+
const size = a.fields.getTextInputValue("Pixelate_Size");
|
|
203
|
+
try {
|
|
204
|
+
const xyArray = xy
|
|
205
|
+
.split(",")
|
|
206
|
+
.map((coord) => parseInt(coord.trim(), 10));
|
|
207
|
+
const whArray = wh
|
|
208
|
+
.split(",")
|
|
209
|
+
.map((coord) => parseInt(coord.trim(), 10));
|
|
210
|
+
if (xyArray.length !== 2 ||
|
|
211
|
+
whArray.length !== 2 ||
|
|
212
|
+
xyArray.some(isNaN) ||
|
|
213
|
+
whArray.some(isNaN)) {
|
|
214
|
+
throw new Error('Invalid format for xy or wh. Use the format "x, y" and "width, height" with valid integer values.');
|
|
215
|
+
}
|
|
216
|
+
const [x, y] = xyArray;
|
|
217
|
+
const [width, height] = whArray;
|
|
218
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
219
|
+
{
|
|
220
|
+
type: "pixelate",
|
|
221
|
+
size: parseInt(size, 10),
|
|
222
|
+
x,
|
|
223
|
+
y,
|
|
224
|
+
w: width,
|
|
225
|
+
h: height,
|
|
226
|
+
},
|
|
227
|
+
]);
|
|
228
|
+
await a.editReply({
|
|
229
|
+
content: "Pixelated Image:",
|
|
230
|
+
files: [processedBuffer],
|
|
231
|
+
ephemeral: true,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error("Error applying pixelate filter:", error);
|
|
236
|
+
await a.editReply({
|
|
237
|
+
content: "Failed to apply pixelate filter: " + error.message,
|
|
238
|
+
ephemeral: true,
|
|
239
|
+
});
|
|
214
240
|
}
|
|
215
|
-
const [x, y] = xyArray;
|
|
216
|
-
const [width, height] = whArray;
|
|
217
|
-
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
218
|
-
{
|
|
219
|
-
type: "pixelate",
|
|
220
|
-
size: parseInt(size, 10),
|
|
221
|
-
x,
|
|
222
|
-
y,
|
|
223
|
-
w: width,
|
|
224
|
-
h: height,
|
|
225
|
-
},
|
|
226
|
-
]);
|
|
227
|
-
await a.editReply({
|
|
228
|
-
content: "Pixelated Image:",
|
|
229
|
-
files: [processedBuffer],
|
|
230
|
-
ephemeral: true,
|
|
231
|
-
});
|
|
232
241
|
}
|
|
233
|
-
|
|
234
|
-
console.error("Error applying pixelate filter:", error);
|
|
242
|
+
else {
|
|
235
243
|
await a.editReply({
|
|
236
|
-
content:
|
|
244
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
237
245
|
ephemeral: true,
|
|
238
246
|
});
|
|
239
247
|
}
|
|
240
248
|
}
|
|
241
|
-
else {
|
|
242
|
-
await a.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
249
|
+
else if (submitId === "Image_Blur") {
|
|
250
|
+
await a.deferReply({ ephemeral: true });
|
|
251
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
252
|
+
const interactionMessage = await a.message.fetch();
|
|
253
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
254
|
+
const totalAttachments = attachmentsArray.length;
|
|
255
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
256
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
257
|
+
const imageURL = selectedAttachment.url;
|
|
258
|
+
const blurRadius = a.fields.getTextInputValue("blur_radius");
|
|
259
|
+
if (blurRadius < 0 || blurRadius > 100) {
|
|
260
|
+
return await a.editReply({
|
|
261
|
+
content: "Value must be between 0-100",
|
|
262
|
+
ephemeral: true,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
267
|
+
{ type: "blur", radius: parseFloat(blurRadius) },
|
|
268
|
+
]);
|
|
269
|
+
await a.editReply({
|
|
270
|
+
content: "Blurred Image:",
|
|
271
|
+
files: [processedBuffer],
|
|
272
|
+
ephemeral: true,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
console.error("Error applying blur filter:", error);
|
|
277
|
+
await a.editReply({
|
|
278
|
+
content: "Failed to apply blur filter: " + error.message,
|
|
279
|
+
ephemeral: true,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
273
282
|
}
|
|
274
|
-
|
|
275
|
-
console.error("Error applying blur filter:", error);
|
|
283
|
+
else {
|
|
276
284
|
await a.editReply({
|
|
277
|
-
content:
|
|
285
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
278
286
|
ephemeral: true,
|
|
279
287
|
});
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
|
-
else {
|
|
283
|
-
await a.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
290
|
+
else if (submitId === "Image_Fade") {
|
|
291
|
+
await a.deferReply({ ephemeral: true });
|
|
292
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
293
|
+
const interactionMessage = await a.message.fetch();
|
|
294
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
295
|
+
const totalAttachments = attachmentsArray.length;
|
|
296
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
297
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
298
|
+
const imageURL = selectedAttachment.url;
|
|
299
|
+
const fadeFactor = a.fields.getTextInputValue("fade_factor");
|
|
300
|
+
if (fadeFactor < 0 || fadeFactor > 1) {
|
|
301
|
+
return await a.editReply({
|
|
302
|
+
content: "Value must be between 0-1",
|
|
303
|
+
ephemeral: true,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
308
|
+
{ type: "fade", factor: parseFloat(fadeFactor) },
|
|
309
|
+
]);
|
|
310
|
+
await a.editReply({
|
|
311
|
+
content: "Faded Image:",
|
|
312
|
+
files: [processedBuffer],
|
|
313
|
+
ephemeral: true,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
console.error("Error applying fade filter:", error);
|
|
318
|
+
await a.editReply({
|
|
319
|
+
content: "Failed to apply fade filter: " + error.message,
|
|
320
|
+
ephemeral: true,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
314
323
|
}
|
|
315
|
-
|
|
316
|
-
console.error("Error applying fade filter:", error);
|
|
324
|
+
else {
|
|
317
325
|
await a.editReply({
|
|
318
|
-
content:
|
|
326
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
319
327
|
ephemeral: true,
|
|
320
328
|
});
|
|
321
329
|
}
|
|
322
330
|
}
|
|
323
|
-
else {
|
|
324
|
-
await a.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
331
|
+
else if (submitId === "Image_Opaque") {
|
|
332
|
+
await a.deferReply({ ephemeral: true });
|
|
333
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
334
|
+
const interactionMessage = await a.message.fetch();
|
|
335
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
336
|
+
const totalAttachments = attachmentsArray.length;
|
|
337
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
338
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
339
|
+
const imageURL = selectedAttachment.url;
|
|
340
|
+
try {
|
|
341
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
342
|
+
{ type: "opaque" },
|
|
343
|
+
]);
|
|
344
|
+
await a.editReply({
|
|
345
|
+
content: "Opaque Image:",
|
|
346
|
+
files: [processedBuffer],
|
|
347
|
+
ephemeral: true,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
console.error("Error applying opaque filter:", error);
|
|
352
|
+
await a.editReply({
|
|
353
|
+
content: "Failed to apply opaque filter: " + error.message,
|
|
354
|
+
ephemeral: true,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
348
357
|
}
|
|
349
|
-
|
|
350
|
-
console.error("Error applying opaque filter:", error);
|
|
358
|
+
else {
|
|
351
359
|
await a.editReply({
|
|
352
|
-
content:
|
|
360
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
353
361
|
ephemeral: true,
|
|
354
362
|
});
|
|
355
363
|
}
|
|
356
364
|
}
|
|
357
|
-
else {
|
|
358
|
-
await a.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
365
|
+
else if (submitId === "Image_GrayScale") {
|
|
366
|
+
await a.deferReply({ ephemeral: true });
|
|
367
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
368
|
+
const interactionMessage = await a.message.fetch();
|
|
369
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
370
|
+
const totalAttachments = attachmentsArray.length;
|
|
371
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
372
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
373
|
+
const imageURL = selectedAttachment.url;
|
|
374
|
+
try {
|
|
375
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
376
|
+
{ type: "greyscale" },
|
|
377
|
+
]);
|
|
378
|
+
await a.editReply({
|
|
379
|
+
content: "Grayscale Image:",
|
|
380
|
+
files: [processedBuffer],
|
|
381
|
+
ephemeral: true,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
console.error("Error applying grayscale filter:", error);
|
|
386
|
+
await a.editReply({
|
|
387
|
+
content: "Failed to apply grayscale filter: " + error.message,
|
|
388
|
+
ephemeral: true,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
382
391
|
}
|
|
383
|
-
|
|
384
|
-
console.error("Error applying grayscale filter:", error);
|
|
392
|
+
else {
|
|
385
393
|
await a.editReply({
|
|
386
|
-
content:
|
|
394
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
387
395
|
ephemeral: true,
|
|
388
396
|
});
|
|
389
397
|
}
|
|
390
398
|
}
|
|
391
|
-
else {
|
|
392
|
-
await a.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
399
|
+
else if (submitId === "Image_Contrast") {
|
|
400
|
+
await a.deferReply({ ephemeral: true });
|
|
401
|
+
const imagePosition = parseInt(a.fields.getTextInputValue("Image_Postion"), 10);
|
|
402
|
+
const interactionMessage = await a.message.fetch();
|
|
403
|
+
const attachmentsArray = Array.from(interactionMessage.attachments.values());
|
|
404
|
+
const totalAttachments = attachmentsArray.length;
|
|
405
|
+
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
406
|
+
const selectedAttachment = attachmentsArray[imagePosition - 1];
|
|
407
|
+
const imageURL = selectedAttachment.url;
|
|
408
|
+
const contrastValue = a.fields.getTextInputValue("Contrast_Value");
|
|
409
|
+
if (contrastValue < 0 || contrastValue > 2) {
|
|
410
|
+
return await a.editReply({
|
|
411
|
+
content: "Value must be between 0-2",
|
|
412
|
+
ephemeral: true,
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
const processedBuffer = await apexPainter.processImage(imageURL, [
|
|
417
|
+
{ type: "contrast", value: parseFloat(contrastValue) },
|
|
418
|
+
]);
|
|
419
|
+
await a.editReply({
|
|
420
|
+
content: "Contrasted Image:",
|
|
421
|
+
files: [processedBuffer],
|
|
422
|
+
ephemeral: true,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
console.error("Error applying contrast filter:", error);
|
|
427
|
+
await a.editReply({
|
|
428
|
+
content: "Failed to apply contrast filter: " + error.message,
|
|
429
|
+
ephemeral: true,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
423
432
|
}
|
|
424
|
-
|
|
425
|
-
console.error("Error applying contrast filter:", error);
|
|
433
|
+
else {
|
|
426
434
|
await a.editReply({
|
|
427
|
-
content:
|
|
435
|
+
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
428
436
|
ephemeral: true,
|
|
429
437
|
});
|
|
430
438
|
}
|
|
431
439
|
}
|
|
432
|
-
else {
|
|
433
|
-
await a.editReply({
|
|
434
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
435
|
-
ephemeral: true,
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
440
|
}
|
|
441
|
+
catch (error) { }
|
|
439
442
|
});
|
|
440
443
|
}
|
|
441
444
|
exports.filters = filters;
|