3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 08:05:03 +00:00

Fixes, refactoring and PR feedback

This commit is contained in:
Lily Bergonzat 2024-04-15 15:51:45 +02:00
parent 0be54912c4
commit 893a77d562
202 changed files with 1037 additions and 1069 deletions

View file

@ -0,0 +1,37 @@
import { ChatInputCommandInteraction, Message } from "discord.js";
import { GuildPluginData } from "knub";
import { ModActionsPluginType } from "../../types";
export async function actualUnhideCaseCmd(
pluginData: GuildPluginData<ModActionsPluginType>,
context: Message | ChatInputCommandInteraction,
caseNumbers: number[],
) {
const failed: number[] = [];
for (const num of caseNumbers) {
const theCase = await pluginData.state.cases.findByCaseNumber(num);
if (!theCase) {
failed.push(num);
continue;
}
await pluginData.state.cases.setHidden(theCase.id, false);
}
if (failed.length === caseNumbers.length) {
pluginData.state.common.sendErrorMessage(context, "None of the cases were found!");
return;
}
const failedAddendum =
failed.length > 0
? `\nThe following cases were not found: ${failed.toString().replace(new RegExp(",", "g"), ", ")}`
: "";
const amt = caseNumbers.length - failed.length;
pluginData.state.common.sendSuccessMessage(
context,
`${amt} case${amt === 1 ? " is" : "s are"} no longer hidden!${failedAddendum}`
);
}