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

WIP: Note Slash Command

This commit is contained in:
Lily Bergonzat 2024-01-22 17:21:05 +01:00
parent 91339bb01e
commit dfb0e2c19d
29 changed files with 319 additions and 178 deletions

View file

@ -0,0 +1,47 @@
import { Attachment, ChatInputCommandInteraction, TextBasedChannel, User } from "discord.js";
import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes";
import { sendSuccessMessage } from "../../../pluginUtils";
import { UnknownUser, renderUserUsername } from "../../../utils";
import { CasesPlugin } from "../../Cases/CasesPlugin";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { ModActionsPluginType } from "../types";
import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
export async function actualNoteCmd(
pluginData: GuildPluginData<ModActionsPluginType>,
context: TextBasedChannel | ChatInputCommandInteraction,
author: User,
attachments: Array<Attachment>,
user: User | UnknownUser,
note: string,
) {
const userName = renderUserUsername(user);
const reason = formatReasonWithAttachments(note, 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,
});
sendSuccessMessage(
pluginData,
context,
`Note added on **${userName}** (Case #${createdCase.case_number})`,
undefined,
undefined,
true,
);
pluginData.state.events.emit("note", user.id, reason);
}