diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-06 01:12:31 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-06 01:12:31 +0100 |
| commit | 9cd5a6e9086d7c9b78f14a02c17279e842d3b908 (patch) | |
| tree | 4a5e748cf1ac456055193ca399fda1dc1bea2af1 /174bg/discord-bot/main.js | |
| parent | 99d0abae50c2dfdfdbcaa4407535da218fc29ae7 (diff) | |
| download | unnamed-group-9cd5a6e9086d7c9b78f14a02c17279e842d3b908.tar unnamed-group-9cd5a6e9086d7c9b78f14a02c17279e842d3b908.tar.gz unnamed-group-9cd5a6e9086d7c9b78f14a02c17279e842d3b908.tar.bz2 unnamed-group-9cd5a6e9086d7c9b78f14a02c17279e842d3b908.tar.xz unnamed-group-9cd5a6e9086d7c9b78f14a02c17279e842d3b908.zip | |
capture and log messages before deleting the channel
Diffstat (limited to '174bg/discord-bot/main.js')
| -rw-r--r-- | 174bg/discord-bot/main.js | 23 |
1 files changed, 20 insertions, 3 deletions
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"), + ), + }, + ], + }); } } }); |
