guild reporting

This commit is contained in:
MathMan05
2026-01-15 17:37:18 -06:00
parent 451fa0e5f7
commit c1332519e3
4 changed files with 50 additions and 1 deletions

View File

@@ -32,6 +32,8 @@ import {ProgessiveDecodeJSON} from "./utils/progessiveLoad.js";
import {MarkDown} from "./markdown.js";
import {Command} from "./interactions/commands.js";
import {Hover} from "./hover.js";
import {ReportMenu} from "./reporting/report.js";
import {getDeveloperSettings} from "./utils/storage/devSettings.js";
export async function makeInviteMenu(inviteMenu: Options, guild: Guild, url: string) {
const invDiv = document.createElement("div");
const bansp = ProgessiveDecodeJSON<invitejson[]>(url, {
@@ -311,6 +313,20 @@ class Guild extends SnowFlake {
navigator.clipboard.writeText(this.id);
},
);
Guild.contextmenu.addButton(
() => I18n.guild.report(),
async function () {
const menu = await ReportMenu.makeReport("guild", this.localuser, {guild: this});
menu?.spawnMenu();
},
{
visible: function () {
const settings = getDeveloperSettings();
return this.properties.owner_id !== this.localuser.user.id && settings.reportSystem;
},
color: "red",
},
);
//TODO mute guild button
}
get muted() {

View File

@@ -15,6 +15,7 @@ import {
reportPut,
reportTypes,
reportUserPut,
reportGuildPut,
} from "./types.js";
interface InfoMap {
message?: Message;
@@ -127,6 +128,17 @@ export class ReportMenu {
realBody = m;
break;
}
case "guild": {
const guild = this.infoMap.guild;
if (!guild) throw new Error("Guild expected");
const m: reportGuildPut = {
...obj,
name: "guild",
guild_id: guild.id,
};
realBody = m;
break;
}
}
const res = await fetch(this.postback_url, {
method: "POST",
@@ -480,6 +492,26 @@ class ReportElement {
div.append(span);
break;
}
case "text": {
const h4 = document.createElement("h4");
h4.textContent = json.data.header;
const p = document.createElement("p");
p.textContent = json.data.body;
div.append(h4, p);
break;
}
case "guild_preview": {
const guild = map.guild;
if (!guild) return;
const guildDiv = document.createElement("div");
guildDiv.classList.add("flexltr");
guildDiv.append(guild.generateGuildIcon(false));
const title = document.createElement("h4");
title.textContent = guild.properties.name;
guildDiv.append(title);
div.append(guildDiv);
break;
}
default:
console.log(json);
div.textContent = this.json.type;

View File

@@ -259,7 +259,7 @@ interface reportGuildDirPut extends reportPut {
guild_id: string;
name: "guild_directory_entry";
}
interface reportGuildPut extends reportPut {
export interface reportGuildPut extends reportPut {
guild_id: string;
name: "guild";
}

View File

@@ -247,6 +247,7 @@
"owner": "Find the owner",
"permission": "Permissions:"
},
"report":"Report Guild",
"admins": "Find Admins",
"all": "all",
"banReason": "Ban reason: $1",