fix: also delete the screenshots message
This commit is contained in:
@@ -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é." });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user