Spaces:
Running
Running
frontend selecting model
Browse files- guildConfigs.json +0 -9
- index.js +31 -7
guildConfigs.json
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"1515307986963267595": {
|
| 3 |
-
"logChannelId": "1515373138937123007",
|
| 4 |
-
"models": {
|
| 5 |
-
"text": "yaya36095/xlm-roberta-text-detector",
|
| 6 |
-
"image": "capcheck/ai-image-detection"
|
| 7 |
-
}
|
| 8 |
-
}
|
| 9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.js
CHANGED
|
@@ -425,13 +425,37 @@ client.on(Events.InteractionCreate, async (interaction) => {
|
|
| 425 |
if (interaction.customId === "setup_save") {
|
| 426 |
const tempSession = activeSetupSessions.get(guildId);
|
| 427 |
if (tempSession) {
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
}
|
| 436 |
}
|
| 437 |
|
|
|
|
| 425 |
if (interaction.customId === "setup_save") {
|
| 426 |
const tempSession = activeSetupSessions.get(guildId);
|
| 427 |
if (tempSession) {
|
| 428 |
+
try {
|
| 429 |
+
const response = await fetch(`http://backend-api-url/guilds/${guildId}/setup`, {
|
| 430 |
+
method: "POST",
|
| 431 |
+
headers: {
|
| 432 |
+
"Content-Type": "application/json"
|
| 433 |
+
},
|
| 434 |
+
body: JSON.stringify({
|
| 435 |
+
active_text_model: tempSession.config.active_text_model || "none",
|
| 436 |
+
log_channel_id: tempSession.config.log_channel_id || null
|
| 437 |
+
})
|
| 438 |
+
});
|
| 439 |
+
|
| 440 |
+
if (!response.ok) {
|
| 441 |
+
const errData = await response.json();
|
| 442 |
+
throw new Error(errData.detail || "Błąd zapisu na backendzie");
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
activeSetupSessions.delete(guildId);
|
| 446 |
+
await interaction.update({
|
| 447 |
+
content: "✅ **Ustawienia zostały pomyślnie zapisane na backendzie!**",
|
| 448 |
+
embeds: [],
|
| 449 |
+
components: []
|
| 450 |
+
});
|
| 451 |
+
} catch (error) {
|
| 452 |
+
console.error("[SETUP ERROR]", error);
|
| 453 |
+
await interaction.update({
|
| 454 |
+
content: `❌ **Wystąpił błąd podczas zapisywania konfiguracji:** ${error.message}`,
|
| 455 |
+
embeds: [],
|
| 456 |
+
components: []
|
| 457 |
+
});
|
| 458 |
+
}
|
| 459 |
}
|
| 460 |
}
|
| 461 |
|