- Settings-Tabelle in SQLite; Env-Variablen nur noch Fallback, Änderungen greifen sofort - /settings (Admin): Devlog-/Commit-Kanal als Dropdown aus allen sichtbaren Textkanälen, je mit Test-senden-Button - Commit-Feed-Regeln: an/aus, Branch-Filter, ignorierte Repos (archiviert wird immer, gefiltert wird nur das Posten; ignorierte Repos komplett übersprungen) - Status-Panel: Bot-Tag, Uptime, Devlog-/Commit-Zahlen, DB-Größe - API: GET/PUT /api/settings, POST /api/settings/test/:target (alles Admin-only) - COMMIT_CHANNEL_ID/DEVLOG_CHANNEL_ID in config optional Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
2.0 KiB
JavaScript
50 lines
2.0 KiB
JavaScript
// /devlog-backfill — komplette Kanal-Historie scannen und alte Devlogs nacharchivieren (Admin only)
|
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from 'discord.js';
|
|
import { devlogChannelId } from '../../runtime-settings.js';
|
|
import { archiveDevlogMessage } from '../devlog-archive.js';
|
|
|
|
export const data = new SlashCommandBuilder()
|
|
.setName('devlog-backfill')
|
|
.setDescription('Archiviert alle bisherigen Devlogs aus dem Devlog-Kanal')
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
|
|
|
|
export async function execute(interaction) {
|
|
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
|
|
|
const targetChannel = devlogChannelId();
|
|
if (!targetChannel) {
|
|
await interaction.editReply('❌ Kein Devlog-Kanal konfiguriert (Settings-Seite im Webinterface).');
|
|
return;
|
|
}
|
|
const channel = await interaction.client.channels.fetch(targetChannel);
|
|
if (!channel?.isTextBased()) {
|
|
await interaction.editReply('❌ Devlog-Kanal nicht gefunden oder kein Textkanal.');
|
|
return;
|
|
}
|
|
|
|
// Historie rückwärts in 100er-Blöcken durchlaufen (Discord-API-Maximum pro Fetch)
|
|
let saved = 0;
|
|
let before;
|
|
// Aufschlüsselung nach Absender-Typ — hilft bei der Diagnose, wenn nichts archiviert wird
|
|
const counts = { webhook: 0, bot: 0, user: 0 };
|
|
for (;;) {
|
|
const batch = await channel.messages.fetch({ limit: 100, before });
|
|
if (batch.size === 0) break;
|
|
|
|
for (const message of batch.values()) {
|
|
if (message.webhookId) counts.webhook++;
|
|
else if (message.author?.bot) counts.bot++;
|
|
else counts.user++;
|
|
if (await archiveDevlogMessage(message)) saved++;
|
|
}
|
|
before = batch.last().id;
|
|
}
|
|
|
|
const scanned = counts.webhook + counts.bot + counts.user;
|
|
await interaction.editReply(
|
|
`✅ Backfill fertig: ${scanned} Nachrichten gescannt ` +
|
|
`(${counts.webhook} Webhook, ${counts.bot} Bot, ${counts.user} User), ` +
|
|
`**${saved} Devlogs neu archiviert**.`
|
|
);
|
|
}
|