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:
parent
1171754e55
commit
ee2cdbf1ce
1 changed files with 11 additions and 0 deletions
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue