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

Update createCase.ts

This commit is contained in:
srqc 2023-02-09 19:44:39 -05:00 committed by GitHub
parent 1171754e55
commit ee2cdbf1ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ 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 { getBaseUrl } from "../../../pluginUtils";
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) { export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
const user = await resolveUser(pluginData.client, args.userId); const user = await resolveUser(pluginData.client, args.userId);
@ -40,7 +41,17 @@ export async function createCase(pluginData: GuildPluginData<CasesPluginType>, a
pp_name: ppName, pp_name: ppName,
is_hidden: Boolean(args.hide), is_hidden: Boolean(args.hide),
}); });
const messagesToArchive = await pluginData.state.savedMessages.getUserMessages(user.id, 50);
const archiveId = await pluginData.state.archives.createFromSavedMessages(messagesToArchive, pluginData.guild);
const baseUrl = getBaseUrl(pluginData);
await createCaseNote(pluginData, {
caseId: createdCase.id,
modId: mod.id,
body: `Automatically archived messages: ${pluginData.state.archives.getUrl(baseUrl, archiveId)}`,
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,