diff --git a/src/webpage/reporting/report.ts b/src/webpage/reporting/report.ts index 5ce884a..42cfb3f 100644 --- a/src/webpage/reporting/report.ts +++ b/src/webpage/reporting/report.ts @@ -17,6 +17,7 @@ import { reportUserPut, reportGuildPut, reportGuildDiscovery, + reportApplicationPut, } from "./types.js"; interface InfoMap { message?: Message; @@ -26,6 +27,7 @@ interface InfoMap { guild?: Guild; guild_id?: string; dyn_preview?: () => HTMLElement; + application_id?: string; } export class ReportMenu { variant: string; @@ -153,6 +155,17 @@ export class ReportMenu { realBody = m; break; } + case "application": { + const id = this.infoMap.application_id; + if (!id) throw new Error("id expected"); + const m: reportApplicationPut = { + ...obj, + name: "application", + application_id: id, + }; + realBody = m; + break; + } } const res = await fetch(this.postback_url, { method: "POST", @@ -300,7 +313,8 @@ class ReportNode { if ( this.buttonType !== "cancel" && this.buttonType !== "done" && - !this.elements.find((e) => e.json.type === "skip") + !this.elements.find((e) => e.json.type === "skip") && + this.owner.nodes.length ) { const back = document.createElement("button"); back.textContent = I18n.report.back(); diff --git a/src/webpage/reporting/types.ts b/src/webpage/reporting/types.ts index fac9450..748ba8e 100644 --- a/src/webpage/reporting/types.ts +++ b/src/webpage/reporting/types.ts @@ -275,7 +275,7 @@ interface reportGuildEventPut extends reportPut { guild_scheduled_event_id: string; name: "guild_scheduled_event"; } -interface reportApplicationPut extends reportPut { +export interface reportApplicationPut extends reportPut { application_id: string; name: "application"; } diff --git a/src/webpage/user.ts b/src/webpage/user.ts index 33a4e46..79192f7 100644 --- a/src/webpage/user.ts +++ b/src/webpage/user.ts @@ -567,6 +567,23 @@ class User extends SnowFlake { color: "red", }, ); + this.contextmenu.addButton( + () => I18n.user.reportApp(), + async function (member) { + const menu = await ReportMenu.makeReport("application", this.localuser, { + user: this, + member, + }); + menu?.spawnMenu(); + }, + { + visible: function () { + const settings = getDeveloperSettings(); + return this.bot && settings.reportSystem; + }, + color: "red", + }, + ); this.contextmenu.addButton( () => I18n.user.instanceBan(), diff --git a/translations/en.json b/translations/en.json index e4fde0a..a55e6df 100644 --- a/translations/en.json +++ b/translations/en.json @@ -811,6 +811,7 @@ "usedFermi": "Used Fermi", "user": { "report":"Report user", + "reportApp":"Report Application", "addRole": "Add roles", "ban": "Ban member", "block": "Block user",