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

Add !deletecase

This commit is contained in:
Dragory 2020-08-09 22:44:07 +03:00
parent 8826b2521d
commit ddbbc543c2
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 146 additions and 6 deletions

View file

@ -1,5 +1,5 @@
import { Case } from "../../../data/entities/Case";
import { MessageContent } from "eris";
import { AdvancedMessageContent, MessageContent } from "eris";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
import { PluginData, helpers } from "knub";
@ -11,13 +11,19 @@ import { chunkLines, chunkMessageLines, emptyEmbedValue } from "../../../utils";
export async function getCaseEmbed(
pluginData: PluginData<CasesPluginType>,
caseOrCaseId: Case | number,
): Promise<MessageContent> {
): Promise<AdvancedMessageContent> {
const theCase = await pluginData.state.cases.with("notes").find(resolveCaseId(caseOrCaseId));
if (!theCase) return null;
const createdAt = moment(theCase.created_at);
const actionTypeStr = CaseTypes[theCase.type].toUpperCase();
let userName = theCase.user_name;
if (theCase.user_id && theCase.user_id !== "0") userName += `\n<@!${theCase.user_id}>`;
let modName = theCase.mod_name;
if (theCase.mod_id) modName += `\n<@!${theCase.mod_id}>`;
const embed: any = {
title: `${actionTypeStr} - Case #${theCase.case_number}`,
footer: {
@ -26,12 +32,12 @@ export async function getCaseEmbed(
fields: [
{
name: "User",
value: `${theCase.user_name}\n<@!${theCase.user_id}>`,
value: userName,
inline: true,
},
{
name: "Moderator",
value: `${theCase.mod_name}\n<@!${theCase.mod_id}>`,
value: modName,
inline: true,
},
],