From 9cd5a6e9086d7c9b78f14a02c17279e842d3b908 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Mon, 6 Jul 2026 01:12:31 +0100 Subject: capture and log messages before deleting the channel --- 174bg/discord-bot/main.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to '174bg/discord-bot') diff --git a/174bg/discord-bot/main.js b/174bg/discord-bot/main.js index d190c04..30c64d4 100644 --- a/174bg/discord-bot/main.js +++ b/174bg/discord-bot/main.js @@ -207,13 +207,30 @@ client.on(Events.InteractionCreate, async (interaction) => { }); } + // fetch all messages in the channel + const messages = await interaction.channel.messages.fetch(); + + // capture channel info before it's deleted (and removed from cache) + const channelId = interaction.channel.id; + const channelName = interaction.channel.name; + // delete the channel await interaction.channel.delete(); // log - sendMessageToLogsChannel( - `<#${interaction.channel.id}> closed by <@${interaction.user.id}>`, - ); + sendMessageToLogsChannel({ + content: `<#${channelId}> closed by <@${interaction.user.id}>`, + files: [ + { + name: `${channelName}.txt`, + attachment: Buffer.from( + messages + .map((message) => `${message.author.tag}: ${message.content}`) + .join("\n"), + ), + }, + ], + }); } } }); -- cgit v1.2.3