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:
parent
91339bb01e
commit
dfb0e2c19d
29 changed files with 319 additions and 178 deletions
47
backend/src/plugins/ModActions/functions/actualNoteCmd.ts
Normal file
47
backend/src/plugins/ModActions/functions/actualNoteCmd.ts
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue