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

Fix case embeds breaking with notes over 1024 chars in length

This commit is contained in:
Dragory 2020-07-29 22:48:49 +03:00
parent 3c90e5d4ab
commit ac714ea307
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 22 additions and 7 deletions

View file

@ -2,10 +2,11 @@ import { Case } from "../../../data/entities/Case";
import { MessageContent } from "eris";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
import { PluginData } from "knub";
import { PluginData, helpers } from "knub";
import { CasesPluginType } from "../types";
import { CaseTypeColors } from "../../../data/CaseTypeColors";
import { resolveCaseId } from "./resolveCaseId";
import { chunkLines, chunkMessageLines, emptyEmbedValue } from "../../../utils";
export async function getCaseEmbed(
pluginData: PluginData<CasesPluginType>,
@ -51,10 +52,21 @@ export async function getCaseEmbed(
if (theCase.notes.length) {
theCase.notes.forEach((note: any) => {
const noteDate = moment(note.created_at);
embed.fields.push({
name: `${note.mod_name} at ${noteDate.format("YYYY-MM-DD [at] HH:mm")}:`,
value: note.body,
});
const chunks = chunkMessageLines(note.body, 1014);
for (let i = 0; i < chunks.length; i++) {
if (i === 0) {
embed.fields.push({
name: `${note.mod_name} at ${noteDate.format("YYYY-MM-DD [at] HH:mm")}:`,
value: chunks[i],
});
} else {
embed.fields.push({
name: emptyEmbedValue,
value: chunks[i],
});
}
}
});
} else {
embed.fields.push({