fix: also delete the screenshots message
All checks were successful
Build and Push Docker Image / typecheck (push) Successful in 24s
Build and Push Docker Image / build (push) Successful in 36s

This commit is contained in:
2026-05-12 19:31:14 +02:00
parent 2f7f8689b2
commit d679a63d3d
5 changed files with 243 additions and 3 deletions

View File

@@ -186,7 +186,8 @@ export const handleReportModal = async (interaction: ModalSubmitInteraction, cli
messageLink = `https://discord.com/channels/${reportChannel.guild.id}/${reportChannel.id}/${reportMessage.id}`;
await db.update(tables.reports).set({ messageLink }).where(eq(tables.reports.id, inserted.id));
if (attachments) {
await reportChannel.send({ files: attachments.map(a => a.url) });
const screenshotsMessage = await reportChannel.send({ files: attachments.map(a => a.url) });
await db.update(tables.reports).set({ screenshotsMessageId: screenshotsMessage.id }).where(eq(tables.reports.id, inserted.id));
}
} else {
logger.error("Invalid 'DISCORD_REPORT_CHANNEL'");
@@ -225,6 +226,16 @@ export const handleDeleteButton = async (interaction: ButtonInteraction, reportI
}
await db.delete(tables.reports).where(eq(tables.reports.id, reportId));
if (report.screenshotsMessageId) {
try {
const screenshotsMsg = await interaction.message.channel.messages.fetch(report.screenshotsMessageId);
await screenshotsMsg.delete();
} catch {
// already deleted or not found
}
}
await interaction.message.delete();
await interaction.editReply({ content: "Signalement supprimé." });
};