FIX: Discord notifikace se od začátku tiše zahazovaly — bot REST fallback
Some checks failed
CI and deploy / deploy (push) Has been cancelled
CI and deploy / migration-check (push) Has started running

Všechny site webhook URL jsou NULL a env DISCORD_WEBHOOK_URL nebyl nastaven
→ send_discord vždy skončil na 'not configured, skipping' (uživatel: 'nikdy
mi nic nepřišlo'). Fix: fallback přes bota (REST POST do DISCORD_EV_CHANNEL_ID
— token už v .env, žádný webhook netřeba); webhook má přednost, kdyby ho
uživatel později nastavil per site. Bot navíc při startu pošle ' online'
(viditelný důkaz, 1× per deploy).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-12 13:44:30 +02:00
parent ee3581da02
commit b651191fdb
2 changed files with 35 additions and 11 deletions

View File

@@ -193,6 +193,13 @@ async def run_discord_bot() -> None:
@client.event
async def on_ready() -> None:
logger.info("Discord bot připojen jako %s", client.user)
try:
channel_id = int(getattr(get_settings(), "discord_ev_channel_id", 0) or 0)
ch = client.get_channel(channel_id) if channel_id else None
if ch is not None:
await ch.send("✅ EMS bot online — notifikace aktivní")
except Exception:
logger.exception("Discord on_ready ping failed")
@client.event
async def on_interaction(interaction: discord.Interaction) -> None: