3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-25 18:25:03 +00:00

Update createCase.ts

This commit is contained in:
srqc 2023-01-13 01:31:00 -05:00 committed by GitHub
parent ba9b3176db
commit e786178e63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,11 +5,8 @@ import { resolveUser } from "../../../utils";
import { CaseArgs, CasesPluginType } from "../types"; import { CaseArgs, CasesPluginType } from "../types";
import { createCaseNote } from "./createCaseNote"; import { createCaseNote } from "./createCaseNote";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel"; import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { getDashboardUrl } from "../../../pluginUtils";
import { CaseTypes } from "../../../data/CaseTypes";
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) { export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
const casesTypesWithoutArchive = [CaseTypes.Note, CaseTypes.Unban];
const user = await resolveUser(pluginData.client, args.userId); const user = await resolveUser(pluginData.client, args.userId);
const userName = user.tag; const userName = user.tag;
@ -44,28 +41,6 @@ export async function createCase(pluginData: GuildPluginData<CasesPluginType>, a
is_hidden: Boolean(args.hide), is_hidden: Boolean(args.hide),
}); });
if (!casesTypesWithoutArchive.includes(args.type)) {
const messagesToArchive = Array.from(await pluginData.state.savedMessages.getUserMessages(user.id, 50)).sort(
(a, b) => (a.posted_at > b.posted_at ? 1 : -1),
);
let noteBody = `No automatic archive was created because no messages were found for this user.`;
if (messagesToArchive.length > 0) {
const archiveId = await pluginData.state.archives.createFromSavedMessages(messagesToArchive, pluginData.guild);
const baseUrl = getDashboardUrl(pluginData);
noteBody = `Automatically archived messages: ${pluginData.state.archives.getUrl(baseUrl, archiveId)}`;
}
await createCaseNote(pluginData, {
caseId: createdCase.id,
modId: mod.id,
body: noteBody,
automatic: args.automatic,
postInCaseLogOverride: false,
});
}
if (args.reason || args.noteDetails?.length) { if (args.reason || args.noteDetails?.length) {
await createCaseNote(pluginData, { await createCaseNote(pluginData, {
caseId: createdCase.id, caseId: createdCase.id,