Discord Webhook Consollen Log + Frab Fehler angepasst
This commit is contained in:
1 parent
81d85a0d68
commit
3ccc38fd17
2 files changed
+34
-9
No files matched your search
@@ -11,15 +11,14 @@ export const CONFIG = {
|
|||||||
B: {
|
B: {
|
||||||
name: "Pierogi", // Name Laila
|
name: "Pierogi", // Name Laila
|
||||||
colorHex: "#3C0061", // Farbe: Lila
|
colorHex: "#3C0061", // Farbe: Lila
|
||||||
colorDiscord: 0x3C0061c, // Discord Embed
|
colorDiscord: 0x3C0061, // Discord Embed
|
||||||
icon: "b.png", // Profilbild
|
icon: "b.png", // Profilbild
|
||||||
background: "bgB.jpg" // Hintergrundbild
|
background: "bgB.jpg" // Hintergrundbild
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Discord Webhook URL
|
// Discord Webhook URL
|
||||||
export const DISCORD_WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL
|
export const DISCORD_WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL;
|
||||||
|| "https://discord.com/api/webhooks/1450872860607381515/zRbiXOykKPUfLJ_H87wD2OxQJPLdro6yQzU2T48Pg4fxSNaXEqBFgxdHGTiIDmmKGHIF";
|
|
||||||
|
|
||||||
// Server URL (für Discord Thumbnails)
|
// Server URL (für Discord Thumbnails)
|
||||||
export const PUBLIC_BASE_URL = process.env.PUBLIC_BASE_URL
|
export const PUBLIC_BASE_URL = process.env.PUBLIC_BASE_URL
|
||||||
|
|||||||
@@ -85,7 +85,10 @@ async function sendDiscordEmbed(previousKey, currentKey, reason) {
|
|||||||
const previous = CONFIG[previousKey];
|
const previous = CONFIG[previousKey];
|
||||||
const current = CONFIG[currentKey];
|
const current = CONFIG[currentKey];
|
||||||
|
|
||||||
if (!DISCORD_WEBHOOK_URL) return;
|
if (!DISCORD_WEBHOOK_URL) {
|
||||||
|
console.log("⚠️ DISCORD_WEBHOOK_URL nicht gesetzt, keine Benachrichtigung gesendet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const fields = [
|
const fields = [
|
||||||
{
|
{
|
||||||
@@ -100,6 +103,7 @@ async function sendDiscordEmbed(previousKey, currentKey, reason) {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Grund hinzufügen falls vorhanden
|
||||||
if (reason) {
|
if (reason) {
|
||||||
fields.push({
|
fields.push({
|
||||||
name: "📝 Grund",
|
name: "📝 Grund",
|
||||||
@@ -111,7 +115,7 @@ async function sendDiscordEmbed(previousKey, currentKey, reason) {
|
|||||||
const embed = {
|
const embed = {
|
||||||
title: "💸 Pay-Switch",
|
title: "💸 Pay-Switch",
|
||||||
description: `**${current.name}**'s turn`,
|
description: `**${current.name}**'s turn`,
|
||||||
color: current.colorDiscord, // ← Verwendet colorDiscord aus config.js
|
color: current.colorDiscord,
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: `${PUBLIC_BASE_URL}/img/${current.icon}`
|
url: `${PUBLIC_BASE_URL}/img/${current.icon}`
|
||||||
},
|
},
|
||||||
@@ -121,16 +125,30 @@ async function sendDiscordEmbed(previousKey, currentKey, reason) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Debug-Ausgabe
|
||||||
|
console.log(`\n📤 Sende Discord Webhook:`);
|
||||||
|
console.log(` Von: ${previous.name} → Zu: ${current.name}`);
|
||||||
|
console.log(` Grund: ${reason || '(keiner)'}`);
|
||||||
|
console.log(` Farbe: 0x${current.colorDiscord.toString(16)}`);
|
||||||
|
console.log(` Webhook URL: ${DISCORD_WEBHOOK_URL.substring(0, 50)}...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(DISCORD_WEBHOOK_URL, {
|
const response = await fetch(DISCORD_WEBHOOK_URL, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ embeds: [embed] })
|
body: JSON.stringify({ embeds: [embed] })
|
||||||
});
|
});
|
||||||
console.log("✅ Discord Benachrichtigung gesendet");
|
|
||||||
|
if (response.ok) {
|
||||||
|
console.log(`✅ Discord Benachrichtigung gesendet (HTTP ${response.status})`);
|
||||||
|
} else {
|
||||||
|
const errorText = await response.text();
|
||||||
|
console.error(`❌ Discord Webhook Fehler (HTTP ${response.status}):`, errorText);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("❌ Discord Webhook Fehler:", err.message);
|
console.error("❌ Discord Webhook Fehler:", err.message);
|
||||||
}
|
}
|
||||||
|
console.log(""); // Leerzeile für bessere Lesbarkeit
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
@@ -178,11 +196,11 @@ app.post("/toggle", async (req, res) => {
|
|||||||
|
|
||||||
const logMessage = reason
|
const logMessage = reason
|
||||||
? `Pay-Switch: ${CONFIG[previousKey].name} → ${CONFIG[state.current].name} (Grund: ${reason})`
|
? `Pay-Switch: ${CONFIG[previousKey].name} → ${CONFIG[state.current].name} (Grund: ${reason})`
|
||||||
: `Pay-Switch: ${CONFIG[previousKey].name} → ${CONFIG[state.current].name}`;
|
: `Pay-Switch: ${CONFIG[previousKey].name} → ${CONFIG[state.current].name} (kein Grund)`;
|
||||||
|
|
||||||
console.log(logMessage);
|
console.log(logMessage);
|
||||||
|
|
||||||
// Discord Benachrichtigung
|
// Discord Benachrichtigung - IMMER senden, auch ohne Grund!
|
||||||
await sendDiscordEmbed(previousKey, state.current, reason);
|
await sendDiscordEmbed(previousKey, state.current, reason);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
@@ -238,6 +256,14 @@ app.listen(PORT, "0.0.0.0", () => {
|
|||||||
console.log(` A: ${CONFIG.A.name} (${CONFIG.A.colorHex})`);
|
console.log(` A: ${CONFIG.A.name} (${CONFIG.A.colorHex})`);
|
||||||
console.log(` B: ${CONFIG.B.name} (${CONFIG.B.colorHex})`);
|
console.log(` B: ${CONFIG.B.name} (${CONFIG.B.colorHex})`);
|
||||||
|
|
||||||
|
// Discord Webhook Test
|
||||||
|
console.log(`\n🔔 Discord Webhook:`);
|
||||||
|
if (DISCORD_WEBHOOK_URL) {
|
||||||
|
console.log(` ✅ Konfiguriert: ${DISCORD_WEBHOOK_URL.substring(0, 50)}...`);
|
||||||
|
} else {
|
||||||
|
console.log(` ❌ NICHT konfiguriert!`);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify critical files exist
|
// Verify critical files exist
|
||||||
const criticalFiles = [
|
const criticalFiles = [
|
||||||
'public/index.html',
|
'public/index.html',
|
||||||
|
|||||||
Reference in new issue
Block a user