apexify.js 4.7.96 → 4.8.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/cjs/ai/ApexAI.d.ts.map +1 -1
- package/dist/cjs/ai/ApexAI.js +1 -5
- package/dist/cjs/ai/ApexAI.js.map +1 -1
- package/dist/cjs/ai/ApexModules.d.ts.map +1 -1
- package/dist/cjs/ai/ApexModules.js +35 -21
- package/dist/cjs/ai/ApexModules.js.map +1 -1
- package/dist/cjs/ai/functions/tokenizer.d.ts +10 -0
- package/dist/cjs/ai/functions/tokenizer.d.ts.map +1 -0
- package/dist/cjs/ai/functions/tokenizer.js +64 -0
- package/dist/cjs/ai/functions/tokenizer.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/chatmodels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/chatmodels.js +8 -11
- package/dist/cjs/ai/modals/electronHub/chatmodels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/imageModels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/imageModels.js +9 -5
- package/dist/cjs/ai/modals/electronHub/imageModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/songModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/electronHub/songModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/speechModels.d.ts.map +1 -0
- package/dist/cjs/ai/{modals-chat → modals}/electronHub/speechModels.js +4 -1
- package/dist/cjs/ai/modals/electronHub/speechModels.js.map +1 -0
- package/dist/cjs/ai/modals/electronHub/videoModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/electronHub/videoModels.js.map +1 -0
- package/dist/cjs/ai/modals/groq/chatgroq.d.ts.map +1 -0
- package/dist/cjs/ai/modals/groq/chatgroq.js.map +1 -0
- package/dist/cjs/ai/modals/groq/imageAnalyzer.d.ts.map +1 -0
- package/dist/cjs/ai/modals/groq/imageAnalyzer.js.map +1 -0
- package/dist/cjs/ai/modals/groq/whisper.d.ts.map +1 -0
- package/dist/cjs/ai/modals/groq/whisper.js.map +1 -0
- package/dist/cjs/ai/modals/hercai/chatModels.d.ts.map +1 -0
- package/dist/cjs/ai/modals/hercai/chatModels.js.map +1 -0
- package/dist/cjs/ai/utils.d.ts +1 -1
- package/dist/cjs/ai/utils.d.ts.map +1 -1
- package/dist/cjs/ai/utils.js +1 -1
- package/dist/cjs/ai/utils.js.map +1 -1
- package/dist/cjs/canvas/ApexPainter.d.ts +1 -1
- package/dist/cjs/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/cjs/canvas/ApexPainter.js +11 -8
- package/dist/cjs/canvas/ApexPainter.js.map +1 -1
- package/dist/cjs/canvas/utils/Image/imageProperties.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/Image/imageProperties.js +47 -24
- package/dist/cjs/canvas/utils/Image/imageProperties.js.map +1 -1
- package/dist/cjs/canvas/utils/types.d.ts +1 -0
- package/dist/cjs/canvas/utils/types.d.ts.map +1 -1
- package/dist/cjs/canvas/utils/types.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/ai/ApexAI.d.ts.map +1 -1
- package/dist/esm/ai/ApexAI.js +1 -5
- package/dist/esm/ai/ApexAI.js.map +1 -1
- package/dist/esm/ai/ApexModules.d.ts.map +1 -1
- package/dist/esm/ai/ApexModules.js +35 -21
- package/dist/esm/ai/ApexModules.js.map +1 -1
- package/dist/esm/ai/functions/tokenizer.d.ts +10 -0
- package/dist/esm/ai/functions/tokenizer.d.ts.map +1 -0
- package/dist/esm/ai/functions/tokenizer.js +64 -0
- package/dist/esm/ai/functions/tokenizer.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/chatmodels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/chatmodels.js +8 -11
- package/dist/esm/ai/modals/electronHub/chatmodels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/imageModels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/imageModels.js +9 -5
- package/dist/esm/ai/modals/electronHub/imageModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/songModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/electronHub/songModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/speechModels.d.ts.map +1 -0
- package/dist/esm/ai/{modals-chat → modals}/electronHub/speechModels.js +4 -1
- package/dist/esm/ai/modals/electronHub/speechModels.js.map +1 -0
- package/dist/esm/ai/modals/electronHub/videoModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/electronHub/videoModels.js.map +1 -0
- package/dist/esm/ai/modals/groq/chatgroq.d.ts.map +1 -0
- package/dist/esm/ai/modals/groq/chatgroq.js.map +1 -0
- package/dist/esm/ai/modals/groq/imageAnalyzer.d.ts.map +1 -0
- package/dist/esm/ai/modals/groq/imageAnalyzer.js.map +1 -0
- package/dist/esm/ai/modals/groq/whisper.d.ts.map +1 -0
- package/dist/esm/ai/modals/groq/whisper.js.map +1 -0
- package/dist/esm/ai/modals/hercai/chatModels.d.ts.map +1 -0
- package/dist/esm/ai/modals/hercai/chatModels.js.map +1 -0
- package/dist/esm/ai/utils.d.ts +1 -1
- package/dist/esm/ai/utils.d.ts.map +1 -1
- package/dist/esm/ai/utils.js +1 -1
- package/dist/esm/ai/utils.js.map +1 -1
- package/dist/esm/canvas/ApexPainter.d.ts +1 -1
- package/dist/esm/canvas/ApexPainter.d.ts.map +1 -1
- package/dist/esm/canvas/ApexPainter.js +11 -8
- package/dist/esm/canvas/ApexPainter.js.map +1 -1
- package/dist/esm/canvas/utils/Image/imageProperties.d.ts.map +1 -1
- package/dist/esm/canvas/utils/Image/imageProperties.js +47 -24
- package/dist/esm/canvas/utils/Image/imageProperties.js.map +1 -1
- package/dist/esm/canvas/utils/types.d.ts +1 -0
- package/dist/esm/canvas/utils/types.d.ts.map +1 -1
- package/dist/esm/canvas/utils/types.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/ai/ApexAI.ts +1 -13
- package/lib/ai/ApexModules.ts +45 -33
- package/lib/ai/functions/tokenizer.ts +69 -0
- package/lib/ai/modals/electronHub/chatmodels.ts +57 -0
- package/lib/ai/{modals-chat → modals}/electronHub/imageModels.ts +17 -13
- package/lib/ai/{modals-chat → modals}/electronHub/speechModels.ts +5 -1
- package/lib/ai/utils.ts +1 -1
- package/lib/canvas/ApexPainter.ts +34 -21
- package/lib/canvas/utils/Image/imageProperties.ts +67 -24
- package/lib/canvas/utils/types.ts +2 -1
- package/package.json +2 -2
- package/dist/cjs/ai/buttons/drawMenu.d.ts +0 -3
- package/dist/cjs/ai/buttons/drawMenu.d.ts.map +0 -1
- package/dist/cjs/ai/buttons/drawMenu.js +0 -273
- package/dist/cjs/ai/buttons/drawMenu.js.map +0 -1
- package/dist/cjs/ai/buttons/tools.d.ts +0 -3
- package/dist/cjs/ai/buttons/tools.d.ts.map +0 -1
- package/dist/cjs/ai/buttons/tools.js +0 -445
- package/dist/cjs/ai/buttons/tools.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/chatmodels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/chatmodels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/imageModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/songModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/songModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/speechModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/speechModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/videoModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/electronHub/videoModels.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/chatgroq.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/chatgroq.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/imageAnalyzer.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/imageAnalyzer.js.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/whisper.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/groq/whisper.js.map +0 -1
- package/dist/cjs/ai/modals-chat/hercai/chatModels.d.ts.map +0 -1
- package/dist/cjs/ai/modals-chat/hercai/chatModels.js.map +0 -1
- package/dist/esm/ai/buttons/drawMenu.d.ts +0 -3
- package/dist/esm/ai/buttons/drawMenu.d.ts.map +0 -1
- package/dist/esm/ai/buttons/drawMenu.js +0 -273
- package/dist/esm/ai/buttons/drawMenu.js.map +0 -1
- package/dist/esm/ai/buttons/tools.d.ts +0 -3
- package/dist/esm/ai/buttons/tools.d.ts.map +0 -1
- package/dist/esm/ai/buttons/tools.js +0 -445
- package/dist/esm/ai/buttons/tools.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/chatmodels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/chatmodels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/imageModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/songModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/songModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/speechModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/speechModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/videoModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/electronHub/videoModels.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/chatgroq.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/chatgroq.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/imageAnalyzer.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/imageAnalyzer.js.map +0 -1
- package/dist/esm/ai/modals-chat/groq/whisper.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/groq/whisper.js.map +0 -1
- package/dist/esm/ai/modals-chat/hercai/chatModels.d.ts.map +0 -1
- package/dist/esm/ai/modals-chat/hercai/chatModels.js.map +0 -1
- package/lib/ai/buttons/drawMenu.ts +0 -361
- package/lib/ai/buttons/tools.ts +0 -551
- package/lib/ai/modals-chat/electronHub/chatmodels.ts +0 -64
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/chatmodels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/imageModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/songModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/songModels.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/speechModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/videoModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/electronHub/videoModels.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/chatgroq.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/chatgroq.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/imageAnalyzer.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/imageAnalyzer.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/whisper.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/groq/whisper.js +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/hercai/chatModels.d.ts +0 -0
- /package/dist/cjs/ai/{modals-chat → modals}/hercai/chatModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/chatmodels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/imageModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/songModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/songModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/speechModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/videoModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/electronHub/videoModels.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/chatgroq.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/chatgroq.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/imageAnalyzer.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/imageAnalyzer.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/whisper.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/groq/whisper.js +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/hercai/chatModels.d.ts +0 -0
- /package/dist/esm/ai/{modals-chat → modals}/hercai/chatModels.js +0 -0
- /package/lib/ai/{modals-chat → modals}/electronHub/songModels.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/electronHub/videoModels.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/groq/chatgroq.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/groq/imageAnalyzer.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/groq/whisper.ts +0 -0
- /package/lib/ai/{modals-chat → modals}/hercai/chatModels.ts +0 -0
package/lib/ai/buttons/tools.ts
DELETED
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
import { ApexPainter } from "../../utils";
|
|
2
|
-
|
|
3
|
-
const apexPainter = new ApexPainter();
|
|
4
|
-
|
|
5
|
-
async function filters(Apex: any) {
|
|
6
|
-
Apex.on("interactionCreate", async (a: any) => {
|
|
7
|
-
try {
|
|
8
|
-
if (!a.isModalSubmit()) return;
|
|
9
|
-
const submitId = a.customId;
|
|
10
|
-
|
|
11
|
-
if (submitId === "resizing_image_zenithmodal") {
|
|
12
|
-
await a.deferReply({ ephemeral: true });
|
|
13
|
-
|
|
14
|
-
const imagePosition = parseInt(
|
|
15
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
16
|
-
10,
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const interactionMessage = await a.message.fetch();
|
|
20
|
-
const attachmentsArray = Array.from(
|
|
21
|
-
interactionMessage.attachments.values(),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const totalAttachments = attachmentsArray.length;
|
|
25
|
-
|
|
26
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
27
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
28
|
-
const imageURL = selectedAttachment.url;
|
|
29
|
-
|
|
30
|
-
const width = a.fields.getTextInputValue("modal_resizingImage_width");
|
|
31
|
-
const height = a.fields.getTextInputValue("modal_resizingImage_height");
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const resizedBuffer = await apexPainter.resize({
|
|
35
|
-
imagePath: imageURL,
|
|
36
|
-
size: { width: parseInt(width, 10), height: parseInt(height, 10) },
|
|
37
|
-
quality: 90
|
|
38
|
-
});
|
|
39
|
-
await a.editReply({
|
|
40
|
-
content: "Resized Image:",
|
|
41
|
-
files: [resizedBuffer],
|
|
42
|
-
ephemeral: true,
|
|
43
|
-
});
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error("Error resizing image:", error);
|
|
46
|
-
await a.editReply({
|
|
47
|
-
content: "Failed to resize image",
|
|
48
|
-
ephemeral: true,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
await a.editReply({
|
|
53
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
54
|
-
ephemeral: true,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} else if (submitId === "Color_Filters") {
|
|
58
|
-
await a.deferReply({ ephemeral: true });
|
|
59
|
-
|
|
60
|
-
const imagePosition = parseInt(
|
|
61
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
62
|
-
10,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const interactionMessage = await a.message.fetch();
|
|
66
|
-
const attachmentsArray = Array.from(
|
|
67
|
-
interactionMessage.attachments.values(),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const totalAttachments = attachmentsArray.length;
|
|
71
|
-
|
|
72
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
73
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
74
|
-
const imageURL = selectedAttachment.url;
|
|
75
|
-
|
|
76
|
-
const hexColor = a.fields.getTextInputValue("color_filter_image");
|
|
77
|
-
|
|
78
|
-
apexPainter.validHex(hexColor);
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
const filteredBuffer = await apexPainter.colorsFilter(
|
|
82
|
-
imageURL,
|
|
83
|
-
hexColor,
|
|
84
|
-
);
|
|
85
|
-
await a.editReply({
|
|
86
|
-
content: "Filtered Image:",
|
|
87
|
-
files: [filteredBuffer],
|
|
88
|
-
ephemeral: true,
|
|
89
|
-
});
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error("Error applying color filter:", error);
|
|
92
|
-
await a.editReply({
|
|
93
|
-
content:
|
|
94
|
-
"Failed to apply color filter. Note: colors need to be in hex code format.",
|
|
95
|
-
ephemeral: true,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
await a.editReply({
|
|
100
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
101
|
-
ephemeral: true,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
} else if (submitId === "Convert_Image_Extension") {
|
|
105
|
-
await a.deferReply({ ephemeral: true });
|
|
106
|
-
|
|
107
|
-
const imagePosition = parseInt(
|
|
108
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
109
|
-
10,
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const interactionMessage = await a.message.fetch();
|
|
113
|
-
const attachmentsArray = Array.from(
|
|
114
|
-
interactionMessage.attachments.values(),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const totalAttachments = attachmentsArray.length;
|
|
118
|
-
|
|
119
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
120
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
121
|
-
const imageURL = selectedAttachment.url;
|
|
122
|
-
|
|
123
|
-
const imageType = a.fields.getTextInputValue("image_type");
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
const convertedBuffer = await apexPainter.imgConverter(
|
|
127
|
-
imageURL,
|
|
128
|
-
imageType,
|
|
129
|
-
);
|
|
130
|
-
await a.editReply({
|
|
131
|
-
content: "Converted Image:",
|
|
132
|
-
files: [convertedBuffer],
|
|
133
|
-
ephemeral: true,
|
|
134
|
-
});
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error("Error converting image extension:", error);
|
|
137
|
-
await a.editReply({
|
|
138
|
-
content: "Failed to convert image extension",
|
|
139
|
-
ephemeral: true,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
await a.editReply({
|
|
144
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
145
|
-
ephemeral: true,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
} else if (submitId === "Image_Brightness") {
|
|
149
|
-
await a.deferReply({ ephemeral: true });
|
|
150
|
-
|
|
151
|
-
const imagePosition = parseInt(
|
|
152
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
153
|
-
10,
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const interactionMessage = await a.message.fetch();
|
|
157
|
-
const attachmentsArray = Array.from(
|
|
158
|
-
interactionMessage.attachments.values(),
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const totalAttachments = attachmentsArray.length;
|
|
162
|
-
|
|
163
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
164
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
165
|
-
const imageURL = selectedAttachment.url;
|
|
166
|
-
|
|
167
|
-
const brightnessDegree =
|
|
168
|
-
a.fields.getTextInputValue("brightness_degree");
|
|
169
|
-
|
|
170
|
-
if (brightnessDegree < 0 || brightnessDegree > 1) {
|
|
171
|
-
return await a.editReply({
|
|
172
|
-
content: "Value must be between 0-1",
|
|
173
|
-
ephemeral: true,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
179
|
-
{ type: "brightness", value: parseFloat(brightnessDegree) },
|
|
180
|
-
]);
|
|
181
|
-
|
|
182
|
-
await a.editReply({
|
|
183
|
-
content: "Brightness Adjusted Image:",
|
|
184
|
-
files: [processedBuffer],
|
|
185
|
-
ephemeral: true,
|
|
186
|
-
});
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.error("Error adjusting image brightness:", error);
|
|
189
|
-
await a.editReply({
|
|
190
|
-
content: "Failed to adjust image brightness",
|
|
191
|
-
ephemeral: true,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
await a.editReply({
|
|
196
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
197
|
-
ephemeral: true,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
} else if (submitId === "Sepia_Filter") {
|
|
201
|
-
await a.deferReply({ ephemeral: true });
|
|
202
|
-
|
|
203
|
-
const imagePosition = parseInt(
|
|
204
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
205
|
-
10,
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
const interactionMessage = await a.message.fetch();
|
|
209
|
-
const attachmentsArray = Array.from(
|
|
210
|
-
interactionMessage.attachments.values(),
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
const totalAttachments = attachmentsArray.length;
|
|
214
|
-
|
|
215
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
216
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
217
|
-
const imageURL = selectedAttachment.url;
|
|
218
|
-
|
|
219
|
-
try {
|
|
220
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
221
|
-
{ type: "sepia" },
|
|
222
|
-
]);
|
|
223
|
-
await a.editReply({
|
|
224
|
-
content: "Applied Sepia Image:",
|
|
225
|
-
files: [processedBuffer],
|
|
226
|
-
ephemeral: true,
|
|
227
|
-
});
|
|
228
|
-
} catch (error) {
|
|
229
|
-
console.error("Error applying sepia:", error);
|
|
230
|
-
await a.editReply({
|
|
231
|
-
content: "Failed to apply sepia filter",
|
|
232
|
-
ephemeral: true,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
await a.editReply({
|
|
237
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
238
|
-
ephemeral: true,
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
} else if (submitId === "Pixelate_Filter") {
|
|
242
|
-
await a.deferReply({ ephemeral: true });
|
|
243
|
-
|
|
244
|
-
const imagePosition = parseInt(
|
|
245
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
246
|
-
10,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
const interactionMessage = await a.message.fetch();
|
|
250
|
-
const attachmentsArray = Array.from(
|
|
251
|
-
interactionMessage.attachments.values(),
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
const totalAttachments = attachmentsArray.length;
|
|
255
|
-
|
|
256
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
257
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
258
|
-
const imageURL = selectedAttachment.url;
|
|
259
|
-
|
|
260
|
-
const xy = a.fields.getTextInputValue("Pixelate_XY");
|
|
261
|
-
const wh = a.fields.getTextInputValue("Pixelate_WH");
|
|
262
|
-
const size = a.fields.getTextInputValue("Pixelate_Size");
|
|
263
|
-
|
|
264
|
-
try {
|
|
265
|
-
const xyArray = xy
|
|
266
|
-
.split(",")
|
|
267
|
-
.map((coord: any) => parseInt(coord.trim(), 10));
|
|
268
|
-
const whArray = wh
|
|
269
|
-
.split(",")
|
|
270
|
-
.map((coord: any) => parseInt(coord.trim(), 10));
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
xyArray.length !== 2 ||
|
|
274
|
-
whArray.length !== 2 ||
|
|
275
|
-
xyArray.some(isNaN) ||
|
|
276
|
-
whArray.some(isNaN)
|
|
277
|
-
) {
|
|
278
|
-
throw new Error(
|
|
279
|
-
'Invalid format for xy or wh. Use the format "x, y" and "width, height" with valid integer values.',
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const [x, y] = xyArray;
|
|
284
|
-
const [width, height] = whArray;
|
|
285
|
-
|
|
286
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
287
|
-
{
|
|
288
|
-
type: "pixelate",
|
|
289
|
-
size: parseInt(size, 10),
|
|
290
|
-
x,
|
|
291
|
-
y,
|
|
292
|
-
w: width,
|
|
293
|
-
h: height,
|
|
294
|
-
},
|
|
295
|
-
]);
|
|
296
|
-
await a.editReply({
|
|
297
|
-
content: "Pixelated Image:",
|
|
298
|
-
files: [processedBuffer],
|
|
299
|
-
ephemeral: true,
|
|
300
|
-
});
|
|
301
|
-
} catch (error: any) {
|
|
302
|
-
console.error("Error applying pixelate filter:", error);
|
|
303
|
-
await a.editReply({
|
|
304
|
-
content: "Failed to apply pixelate filter: " + error.message,
|
|
305
|
-
ephemeral: true,
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
} else {
|
|
309
|
-
await a.editReply({
|
|
310
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
311
|
-
ephemeral: true,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
} else if (submitId === "Image_Blur") {
|
|
315
|
-
await a.deferReply({ ephemeral: true });
|
|
316
|
-
|
|
317
|
-
const imagePosition = parseInt(
|
|
318
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
319
|
-
10,
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
const interactionMessage = await a.message.fetch();
|
|
323
|
-
const attachmentsArray = Array.from(
|
|
324
|
-
interactionMessage.attachments.values(),
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
const totalAttachments = attachmentsArray.length;
|
|
328
|
-
|
|
329
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
330
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
331
|
-
const imageURL = selectedAttachment.url;
|
|
332
|
-
|
|
333
|
-
const blurRadius = a.fields.getTextInputValue("blur_radius");
|
|
334
|
-
|
|
335
|
-
if (blurRadius < 0 || blurRadius > 100) {
|
|
336
|
-
return await a.editReply({
|
|
337
|
-
content: "Value must be between 0-100",
|
|
338
|
-
ephemeral: true,
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
try {
|
|
343
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
344
|
-
{ type: "blur", radius: parseFloat(blurRadius) },
|
|
345
|
-
]);
|
|
346
|
-
await a.editReply({
|
|
347
|
-
content: "Blurred Image:",
|
|
348
|
-
files: [processedBuffer],
|
|
349
|
-
ephemeral: true,
|
|
350
|
-
});
|
|
351
|
-
} catch (error: any) {
|
|
352
|
-
console.error("Error applying blur filter:", error);
|
|
353
|
-
await a.editReply({
|
|
354
|
-
content: "Failed to apply blur filter: " + error.message,
|
|
355
|
-
ephemeral: true,
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
} else {
|
|
359
|
-
await a.editReply({
|
|
360
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
361
|
-
ephemeral: true,
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
} else if (submitId === "Image_Fade") {
|
|
365
|
-
await a.deferReply({ ephemeral: true });
|
|
366
|
-
|
|
367
|
-
const imagePosition = parseInt(
|
|
368
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
369
|
-
10,
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
const interactionMessage = await a.message.fetch();
|
|
373
|
-
const attachmentsArray = Array.from(
|
|
374
|
-
interactionMessage.attachments.values(),
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
const totalAttachments = attachmentsArray.length;
|
|
378
|
-
|
|
379
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
380
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
381
|
-
const imageURL = selectedAttachment.url;
|
|
382
|
-
|
|
383
|
-
const fadeFactor = a.fields.getTextInputValue("fade_factor");
|
|
384
|
-
|
|
385
|
-
if (fadeFactor < 0 || fadeFactor > 1) {
|
|
386
|
-
return await a.editReply({
|
|
387
|
-
content: "Value must be between 0-1",
|
|
388
|
-
ephemeral: true,
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
try {
|
|
393
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
394
|
-
{ type: "fade", factor: parseFloat(fadeFactor) },
|
|
395
|
-
]);
|
|
396
|
-
await a.editReply({
|
|
397
|
-
content: "Faded Image:",
|
|
398
|
-
files: [processedBuffer],
|
|
399
|
-
ephemeral: true,
|
|
400
|
-
});
|
|
401
|
-
} catch (error: any) {
|
|
402
|
-
console.error("Error applying fade filter:", error);
|
|
403
|
-
await a.editReply({
|
|
404
|
-
content: "Failed to apply fade filter: " + error.message,
|
|
405
|
-
ephemeral: true,
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
} else {
|
|
409
|
-
await a.editReply({
|
|
410
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
411
|
-
ephemeral: true,
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
} else if (submitId === "Image_Opaque") {
|
|
415
|
-
await a.deferReply({ ephemeral: true });
|
|
416
|
-
|
|
417
|
-
const imagePosition = parseInt(
|
|
418
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
419
|
-
10,
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
const interactionMessage = await a.message.fetch();
|
|
423
|
-
const attachmentsArray = Array.from(
|
|
424
|
-
interactionMessage.attachments.values(),
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
const totalAttachments = attachmentsArray.length;
|
|
428
|
-
|
|
429
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
430
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
431
|
-
const imageURL = selectedAttachment.url;
|
|
432
|
-
|
|
433
|
-
try {
|
|
434
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
435
|
-
{ type: "opaque" },
|
|
436
|
-
]);
|
|
437
|
-
await a.editReply({
|
|
438
|
-
content: "Opaque Image:",
|
|
439
|
-
files: [processedBuffer],
|
|
440
|
-
ephemeral: true,
|
|
441
|
-
});
|
|
442
|
-
} catch (error: any) {
|
|
443
|
-
console.error("Error applying opaque filter:", error);
|
|
444
|
-
await a.editReply({
|
|
445
|
-
content: "Failed to apply opaque filter: " + error.message,
|
|
446
|
-
ephemeral: true,
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
} else {
|
|
450
|
-
await a.editReply({
|
|
451
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
452
|
-
ephemeral: true,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
} else if (submitId === "Image_GrayScale") {
|
|
456
|
-
await a.deferReply({ ephemeral: true });
|
|
457
|
-
|
|
458
|
-
const imagePosition = parseInt(
|
|
459
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
460
|
-
10,
|
|
461
|
-
);
|
|
462
|
-
|
|
463
|
-
const interactionMessage = await a.message.fetch();
|
|
464
|
-
const attachmentsArray = Array.from(
|
|
465
|
-
interactionMessage.attachments.values(),
|
|
466
|
-
);
|
|
467
|
-
|
|
468
|
-
const totalAttachments = attachmentsArray.length;
|
|
469
|
-
|
|
470
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
471
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
472
|
-
const imageURL = selectedAttachment.url;
|
|
473
|
-
|
|
474
|
-
try {
|
|
475
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
476
|
-
{ type: "greyscale" },
|
|
477
|
-
]);
|
|
478
|
-
await a.editReply({
|
|
479
|
-
content: "Grayscale Image:",
|
|
480
|
-
files: [processedBuffer],
|
|
481
|
-
ephemeral: true,
|
|
482
|
-
});
|
|
483
|
-
} catch (error: any) {
|
|
484
|
-
console.error("Error applying grayscale filter:", error);
|
|
485
|
-
await a.editReply({
|
|
486
|
-
content: "Failed to apply grayscale filter: " + error.message,
|
|
487
|
-
ephemeral: true,
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
await a.editReply({
|
|
492
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
493
|
-
ephemeral: true,
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
} else if (submitId === "Image_Contrast") {
|
|
497
|
-
await a.deferReply({ ephemeral: true });
|
|
498
|
-
|
|
499
|
-
const imagePosition = parseInt(
|
|
500
|
-
a.fields.getTextInputValue("Image_Postion"),
|
|
501
|
-
10,
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
const interactionMessage = await a.message.fetch();
|
|
505
|
-
const attachmentsArray = Array.from(
|
|
506
|
-
interactionMessage.attachments.values(),
|
|
507
|
-
);
|
|
508
|
-
|
|
509
|
-
const totalAttachments = attachmentsArray.length;
|
|
510
|
-
|
|
511
|
-
if (imagePosition >= 1 && imagePosition <= totalAttachments) {
|
|
512
|
-
const selectedAttachment = attachmentsArray[imagePosition - 1] as any;
|
|
513
|
-
const imageURL = selectedAttachment.url;
|
|
514
|
-
|
|
515
|
-
const contrastValue = a.fields.getTextInputValue("Contrast_Value");
|
|
516
|
-
|
|
517
|
-
if (contrastValue < 0 || contrastValue > 2) {
|
|
518
|
-
return await a.editReply({
|
|
519
|
-
content: "Value must be between 0-2",
|
|
520
|
-
ephemeral: true,
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
try {
|
|
525
|
-
const processedBuffer = await apexPainter.effects(imageURL, [
|
|
526
|
-
{ type: "contrast", value: parseFloat(contrastValue) },
|
|
527
|
-
]);
|
|
528
|
-
await a.editReply({
|
|
529
|
-
content: "Contrasted Image:",
|
|
530
|
-
files: [processedBuffer],
|
|
531
|
-
ephemeral: true,
|
|
532
|
-
});
|
|
533
|
-
} catch (error: any) {
|
|
534
|
-
console.error("Error applying contrast filter:", error);
|
|
535
|
-
await a.editReply({
|
|
536
|
-
content: "Failed to apply contrast filter: " + error.message,
|
|
537
|
-
ephemeral: true,
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
} else {
|
|
541
|
-
await a.editReply({
|
|
542
|
-
content: `Invalid image position. Please select a position between 1 and ${totalAttachments}.`,
|
|
543
|
-
ephemeral: true,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
} catch (error: any) {}
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export { filters };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
export async function electronChat({
|
|
3
|
-
ApiKey,
|
|
4
|
-
prompt,
|
|
5
|
-
modelName,
|
|
6
|
-
instruction,
|
|
7
|
-
}: {
|
|
8
|
-
ApiKey?: string;
|
|
9
|
-
prompt: string;
|
|
10
|
-
modelName: string;
|
|
11
|
-
instruction?: string;
|
|
12
|
-
}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (modelName === "claude-3-sonnet-200k") {
|
|
16
|
-
modelName = "claude-3-sonnet-20240229";
|
|
17
|
-
} else if (modelName === "claude-3.5-sonnet-200k") {
|
|
18
|
-
modelName = "claude-3.5-sonnet-20240620";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const apiKey = ApiKey || "ek-3gmOPmvuljmrl4NQrohpnp1ryNXQG5bNn08zNuzhX6bcxBrndR";
|
|
23
|
-
const openai = new OpenAI({
|
|
24
|
-
apiKey: apiKey,
|
|
25
|
-
baseURL: "https://api.electronhub.top/v1",
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const models = await openai.models.list();
|
|
29
|
-
|
|
30
|
-
const modelExists = models.data.some((model: any) => model.id === modelName);
|
|
31
|
-
|
|
32
|
-
if (!modelExists) {
|
|
33
|
-
throw new Error('Invalid model name please check out Electron hub models for more info.')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const completion = await openai.chat.completions.create({
|
|
37
|
-
model: modelName,
|
|
38
|
-
messages: [
|
|
39
|
-
{"role": "system", "content": `${instruction}`},
|
|
40
|
-
{"role": "user", "content": `${prompt}`}
|
|
41
|
-
]
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return completion.choices[0]?.message?.content;
|
|
46
|
-
} catch (e: any) {
|
|
47
|
-
if (e.response) {
|
|
48
|
-
if (e.response.status === 429) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Rate limit exceeded. Please join the server at https://discord.gg/83XcjD8vgW for an API key."
|
|
51
|
-
);
|
|
52
|
-
} else if (e.response.status === 500) {
|
|
53
|
-
throw new Error("Server error. Please try again later.");
|
|
54
|
-
} else {
|
|
55
|
-
console.error("Error generating response:", e.response.data);
|
|
56
|
-
throw e;
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
console.error("Error generating response:", e.message);
|
|
60
|
-
throw e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|