report apps

This commit is contained in:
MathMan05
2026-01-15 18:14:14 -06:00
parent 7c021234b3
commit 98e8b9083c
4 changed files with 34 additions and 2 deletions

View File

@@ -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();

View File

@@ -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";
}

View File

@@ -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(),

View File

@@ -811,6 +811,7 @@
"usedFermi": "Used Fermi",
"user": {
"report":"Report user",
"reportApp":"Report Application",
"addRole": "Add roles",
"ban": "Ban member",
"block": "Block user",