Feature 3: Devlog-Archiv — Live-Listener + /devlog-backfill

- Webhook-Nachrichten im Devlog-Kanal werden automatisch in SQLite archiviert
  (devlog.py im EcoGame-Repo bleibt unverändert)
- /devlog-backfill (Admin): scannt die komplette Kanal-Historie in 100er-Blöcken
- Dedupe über Discord-Message-ID, Embeds werden mit Titel+Beschreibung erfasst
- Neue Intents: GuildMessages + MessageContent, neue Env-Var DEVLOG_CHANNEL_ID

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 23:51:16 +02:00
co-authored by Claude Opus 4.8
parent 716268b1c1
commit 2c63c62e14
8 changed files with 152 additions and 5 deletions
+22 -2
View File
@@ -1,14 +1,22 @@
// Discord-Client: Commands laden, registrieren und Interactions verarbeiten
import { Client, Collection, Events, GatewayIntentBits, REST, Routes } from 'discord.js';
import { config } from '../config.js';
import { archiveDevlogMessage } from './devlog-archive.js';
import * as ping from './commands/ping.js';
import * as devlogBackfill from './commands/devlog-backfill.js';
// Alle Commands hier eintragen — jedes Modul exportiert { data, execute }
const commandModules = [ping];
const commandModules = [ping, devlogBackfill];
export async function startBot() {
const client = new Client({
intents: [GatewayIntentBits.Guilds],
intents: [
GatewayIntentBits.Guilds,
// Für das Devlog-Archiv: Nachrichten im Devlog-Kanal mitlesen
// (erfordert aktivierten "Message Content Intent" im Developer Portal!)
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
// Commands in Collection ablegen für schnellen Zugriff im Interaction-Handler
@@ -22,6 +30,18 @@ export async function startBot() {
await registerCommands();
});
// Live-Archivierung: neue Devlogs (Webhook-Posts im Devlog-Kanal) sofort sichern
client.on(Events.MessageCreate, (message) => {
if (message.channelId !== config.devlogChannelId) return;
try {
if (archiveDevlogMessage(message)) {
console.log(`[devlog] Neues Devlog archiviert (${message.id})`);
}
} catch (error) {
console.error('[devlog] Archivierung fehlgeschlagen:', error);
}
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;