Skip to content

Commit

Permalink
move embed fields to embed description
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
metal0 authored Nov 26, 2023
1 parent 6c0d27d commit 14b8420
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions backend/src/plugins/ModActions/commands/CasesModCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { sendErrorMessage } from "../../../pluginUtils";
import { emptyEmbedValue, resolveUser, trimLines } from "../../../utils";
import { asyncMap } from "../../../utils/async";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { modActionsCmd } from "../types";
Expand All @@ -13,7 +12,7 @@ const opts = {
mod: ct.userId({ option: true }),
};

const casesPerPage = 5;
const casesPerPage = 10;

export const CasesModCmd = modActionsCmd({
trigger: ["cases", "modlogs", "infractions"],
Expand Down Expand Up @@ -50,17 +49,18 @@ export const CasesModCmd = modActionsCmd({
const cases = await casesPlugin.getRecentCasesByMod(modId, casesPerPage, (page - 1) * casesPerPage);
const lines = await asyncMap(cases, (c) => casesPlugin.getCaseSummary(c, true, msg.author.id));

const isLastPage = page === totalPages;
const firstCaseNum = (page - 1) * casesPerPage + 1;
const lastCaseNum = page * casesPerPage;
const lastCaseNum = isLastPage ? totalCases : page * casesPerPage;
const title = `Most recent cases ${firstCaseNum}-${lastCaseNum} of ${totalCases} by ${modName}`;

const embed = {
author: {
name: title,
icon_url: mod instanceof User ? mod.displayAvatarURL() : undefined,
},
description: lines.join("\n"),
fields: [
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),
{
name: emptyEmbedValue,
value: trimLines(`
Expand Down
9 changes: 3 additions & 6 deletions backend/src/plugins/ModActions/commands/CasesUserCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
import { UnknownUser, chunkArray, emptyEmbedValue, renderUserUsername, resolveUser, trimLines } from "../../../utils";
import { asyncMap } from "../../../utils/async";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage.js";
import { getChunkedEmbedFields } from "../../../utils/getChunkedEmbedFields";
import { getGuildPrefix } from "../../../utils/getGuildPrefix";
import { modActionsCmd } from "../types";

Expand Down Expand Up @@ -107,7 +106,7 @@ export const CasesUserCmd = modActionsCmd({

const isLastPage = page === totalPages;
const firstCaseNum = (page - 1) * casesPerPage + 1;
const lastCaseNum = page * casesPerPage;
const lastCaseNum = isLastPage ? cases.length : page * casesPerPage;
const title =
totalPages === 1
? `Cases for ${userName} (${lines.length} total)`
Expand All @@ -118,13 +117,11 @@ export const CasesUserCmd = modActionsCmd({
name: title,
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
},
description: lines.join("\n"),
fields: [
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),
{
name: emptyEmbedValue,
value: trimLines(`
Use \`${prefix}case <num>\` to see more information about an individual case
`),
value: trimLines(`Use \`${prefix}case <num>\` to see more information about an individual case`),
},
],
} satisfies APIEmbed;
Expand Down

0 comments on commit 14b8420

Please sign in to comment.