3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-07 11:07:19 +00:00

Merge remote-tracking branch 'origin' into next

This commit is contained in:
Dragory 2024-08-11 21:44:16 +03:00
commit cb2306e522
No known key found for this signature in database
26 changed files with 163 additions and 96 deletions

View file

@ -3,7 +3,14 @@ import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { CaseTypes } from "../../../data/CaseTypes.js";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin.js";
import { UnknownUser, chunkArray, emptyEmbedValue, renderUsername, resolveMember, resolveUser } from "../../../utils.js";
import {
UnknownUser,
chunkArray,
emptyEmbedValue,
renderUsername,
resolveMember,
resolveUser,
} from "../../../utils.js";
import { asyncMap } from "../../../utils/async.js";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage.js";
import { getGuildPrefix } from "../../../utils/getGuildPrefix.js";
@ -95,7 +102,7 @@ export const CasesUserCmd = modActionsCmd({
// Compact view (= regular message with a preview of each case)
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const totalPages = Math.max(Math.ceil(cases.length / casesPerPage), 1);
const totalPages = Math.max(Math.ceil(casesToDisplay.length / casesPerPage), 1);
const prefix = getGuildPrefix(pluginData);
createPaginatedMessage(
@ -103,16 +110,16 @@ export const CasesUserCmd = modActionsCmd({
msg.channel,
totalPages,
async (page) => {
const chunkedCases = chunkArray(cases, casesPerPage)[page - 1];
const chunkedCases = chunkArray(casesToDisplay, casesPerPage)[page - 1];
const lines = await asyncMap(chunkedCases, (c) => casesPlugin.getCaseSummary(c, true, msg.author.id));
const isLastPage = page === totalPages;
const firstCaseNum = (page - 1) * casesPerPage + 1;
const lastCaseNum = isLastPage ? cases.length : page * casesPerPage;
const lastCaseNum = isLastPage ? casesToDisplay.length : page * casesPerPage;
const title =
totalPages === 1
? `Cases for ${userName} (${lines.length} total)`
: `Most recent cases ${firstCaseNum}-${lastCaseNum} of ${cases.length} for ${userName}`;
: `Most recent cases ${firstCaseNum}-${lastCaseNum} of ${casesToDisplay.length} for ${userName}`;
const embed = {
author: {

View file

@ -3,7 +3,13 @@ import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes.js";
import { LogType } from "../../../data/LogType.js";
import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter.js";
import { createUserNotificationError, notifyUser, resolveUser, ucfirst, UserNotificationResult } from "../../../utils.js";
import {
createUserNotificationError,
notifyUser,
resolveUser,
ucfirst,
UserNotificationResult,
} from "../../../utils.js";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
import { LogsPlugin } from "../../Logs/LogsPlugin.js";

View file

@ -2,7 +2,13 @@ import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes.js";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
import { UserNotificationResult, createUserNotificationError, notifyUser, resolveUser, ucfirst } from "../../../utils.js";
import {
UserNotificationResult,
createUserNotificationError,
notifyUser,
resolveUser,
ucfirst,
} from "../../../utils.js";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
import { waitForButtonConfirm } from "../../../utils/waitForInteraction.js";
import { CasesPlugin } from "../../Cases/CasesPlugin.js";