WIP ModActions
This commit is contained in:
parent
a3d0ec03d9
commit
ebcb28261b
25 changed files with 1162 additions and 6 deletions
44
backend/src/plugins/ModActions/commands/NoteCmd.ts
Normal file
44
backend/src/plugins/ModActions/commands/NoteCmd.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
import { modActionsCommand } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
|
||||
import { CasesPlugin } from "../../Cases/CasesPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { resolveUser, stripObjectToScalars } from "../../../utils";
|
||||
|
||||
export const NoteCmd = modActionsCommand({
|
||||
trigger: "note",
|
||||
permission: "can_note",
|
||||
description: "Add a note to the specified user",
|
||||
|
||||
signature: {
|
||||
user: ct.string(),
|
||||
note: ct.string({ catchAll: true }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
const user = await resolveUser(pluginData.client, args.user);
|
||||
if (!user) return sendErrorMessage(pluginData, msg.channel, `User not found`);
|
||||
|
||||
const userName = `${user.username}#${user.discriminator}`;
|
||||
const reason = formatReasonWithAttachments(args.note, msg.attachments);
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const createdCase = await casesPlugin.createCase({
|
||||
userId: user.id,
|
||||
modId: msg.author.id,
|
||||
type: CaseTypes.Note,
|
||||
reason,
|
||||
});
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_NOTE, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
user: stripObjectToScalars(user, ["user", "roles"]),
|
||||
reason,
|
||||
});
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel, `Note added on **${userName}** (Case #${createdCase.case_number})`);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue