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}`; 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)); await db.update(tables.reports).set({ messageLink }).where(eq(tables.reports.id, inserted.id));
if (attachments) { 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 { } else {
logger.error("Invalid 'DISCORD_REPORT_CHANNEL'"); 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)); 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.message.delete();
await interaction.editReply({ content: "Signalement supprimé." }); await interaction.editReply({ content: "Signalement supprimé." });
}; };

View File

@@ -0,0 +1 @@
ALTER TABLE "reports" ADD COLUMN "screenshots_message_id" text;

View File

@@ -0,0 +1,220 @@
{
"id": "a19383ff-8e7a-4da4-8c29-888e8ea9f670",
"prevId": "4643e6bd-db18-44c9-893d-8f57a94e8c0a",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.accounts": {
"name": "accounts",
"schema": "",
"columns": {
"player_id": {
"name": "player_id",
"type": "uuid",
"primaryKey": true,
"notNull": true
},
"balance": {
"name": "balance",
"type": "integer",
"primaryKey": false,
"notNull": true,
"default": 0
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.reports": {
"name": "reports",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"reporter_id": {
"name": "reporter_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"reporter_username": {
"name": "reporter_username",
"type": "text",
"primaryKey": false,
"notNull": true
},
"player_name": {
"name": "player_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"player_id": {
"name": "player_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"reason": {
"name": "reason",
"type": "text",
"primaryKey": false,
"notNull": true
},
"screenshots": {
"name": "screenshots",
"type": "text",
"primaryKey": false,
"notNull": false
},
"message_link": {
"name": "message_link",
"type": "text",
"primaryKey": false,
"notNull": false
},
"screenshots_message_id": {
"name": "screenshots_message_id",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.tracked_players": {
"name": "tracked_players",
"schema": "",
"columns": {
"player_id": {
"name": "player_id",
"type": "uuid",
"primaryKey": true,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.username_history": {
"name": "username_history",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"player_id": {
"name": "player_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true
},
"first_seen_at": {
"name": "first_seen_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"username_history_player_id_tracked_players_player_id_fk": {
"name": "username_history_player_id_tracked_players_player_id_fk",
"tableFrom": "username_history",
"tableTo": "tracked_players",
"columnsFrom": [
"player_id"
],
"columnsTo": [
"player_id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -22,6 +22,13 @@
"when": 1778605638295, "when": 1778605638295,
"tag": "0002_lucky_praxagora", "tag": "0002_lucky_praxagora",
"breakpoints": true "breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1778607030657,
"tag": "0003_uneven_mephistopheles",
"breakpoints": true
} }
] ]
} }

View File

@@ -12,6 +12,7 @@ export const reports = pgTable("reports", {
reason: text("reason").notNull(), reason: text("reason").notNull(),
screenshots: text("screenshots"), screenshots: text("screenshots"),
messageLink: text("message_link"), messageLink: text("message_link"),
screenshotsMessageId: text("screenshots_message_id"),
createdAt: timestamp("created_at").notNull().defaultNow(), createdAt: timestamp("created_at").notNull().defaultNow(),
}); });