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
4aeaf8eee1
commit
bce15b1cfa
1 changed files with 14 additions and 10 deletions
|
@ -6,8 +6,10 @@ 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";
|
import { getBaseUrl } 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;
|
||||||
|
|
||||||
|
@ -41,10 +43,10 @@ export async function createCase(pluginData: GuildPluginData<CasesPluginType>, a
|
||||||
pp_name: ppName,
|
pp_name: ppName,
|
||||||
is_hidden: Boolean(args.hide),
|
is_hidden: Boolean(args.hide),
|
||||||
});
|
});
|
||||||
|
if (!casesTypesWithoutArchive.includes(args.type)) {
|
||||||
const messagesToArchive = await pluginData.state.savedMessages.getUserMessages(user.id, 50);
|
const messagesToArchive = await pluginData.state.savedMessages.getUserMessages(user.id, 50);
|
||||||
const archiveId = await pluginData.state.archives.createFromSavedMessages(messagesToArchive, pluginData.guild);
|
const archiveId = await pluginData.state.archives.createFromSavedMessages(messagesToArchive, pluginData.guild);
|
||||||
const baseUrl = getBaseUrl(pluginData);
|
const baseUrl = getBaseUrl(pluginData);
|
||||||
|
|
||||||
await createCaseNote(pluginData, {
|
await createCaseNote(pluginData, {
|
||||||
caseId: createdCase.id,
|
caseId: createdCase.id,
|
||||||
modId: mod.id,
|
modId: mod.id,
|
||||||
|
@ -52,6 +54,8 @@ export async function createCase(pluginData: GuildPluginData<CasesPluginType>, a
|
||||||
automatic: args.automatic,
|
automatic: args.automatic,
|
||||||
postInCaseLogOverride: false,
|
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