3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 13:55: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

@ -1,53 +0,0 @@
import { Attachment, ChatInputCommandInteraction, Message, User } from "discord.js";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../../data/CaseTypes";
import { UnknownUser, renderUsername } from "../../../../utils";
import { CasesPlugin } from "../../../Cases/CasesPlugin";
import { CommonPlugin } from "../../../Common/CommonPlugin";
import { LogsPlugin } from "../../../Logs/LogsPlugin";
import { ModActionsPluginType } from "../../types";
import { handleAttachmentLinkDetectionAndGetRestriction } from "../attachmentLinkReaction";
import { formatReasonWithMessageLinkForAttachments } from "../formatReasonForAttachments";
export async function actualNoteCmd(
pluginData: GuildPluginData<ModActionsPluginType>,
context: Message | ChatInputCommandInteraction,
author: User,
attachments: Array<Attachment>,
user: User | UnknownUser,
note: string,
) {
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, note)) {
return;
}
const userName = renderUsername(user);
const reason = await formatReasonWithMessageLinkForAttachments(pluginData, note, context, attachments);
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const createdCase = await casesPlugin.createCase({
userId: user.id,
modId: author.id,
type: CaseTypes.Note,
reason,
});
pluginData.getPlugin(LogsPlugin).logMemberNote({
mod: author,
user,
caseNumber: createdCase.case_number,
reason,
});
pluginData
.getPlugin(CommonPlugin)
.sendSuccessMessage(
context,
`Note added on **${userName}** (Case #${createdCase.case_number})`,
undefined,
undefined,
true,
);
pluginData.state.events.emit("note", user.id, reason);
}