mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 01:25:02 +00:00
feat(mod-actions): require reason
This commit is contained in:
parent
2b8f75b91b
commit
529a0bfc0e
9 changed files with 39 additions and 1 deletions
|
@ -84,6 +84,7 @@ const defaultOptions = {
|
|||
can_deletecase: false,
|
||||
can_act_as_other: false,
|
||||
create_cases_for_manual_actions: true,
|
||||
require_reason: ["warn"],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ import { isBanned } from "../functions/isBanned";
|
|||
import { readContactMethodsFromArgs } from "../functions/readContactMethodsFromArgs";
|
||||
import { modActionsCmd } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { TextChannel } from "discord.js";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
@ -52,7 +53,13 @@ export const BanCmd = modActionsCmd({
|
|||
}
|
||||
const time = args["time"] ? args["time"] : null;
|
||||
|
||||
const config = pluginData.config.get();
|
||||
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
||||
if (!reason && config.require_reason.includes("ban")) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You must include a reason in your ban");
|
||||
return;
|
||||
}
|
||||
|
||||
const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = msg.member;
|
||||
|
|
|
@ -32,7 +32,12 @@ export const NoteCmd = modActionsCmd({
|
|||
}
|
||||
|
||||
const userName = user.tag;
|
||||
const reason = formatReasonWithAttachments(args.note, [...msg.attachments.values()]);
|
||||
const config = pluginData.config.get();
|
||||
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
||||
if (!reason && config.require_reason.includes("note")) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You must include a reason in your note");
|
||||
return;
|
||||
}
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const createdCase = await casesPlugin.createCase({
|
||||
|
|
|
@ -48,7 +48,12 @@ export const UnbanCmd = modActionsCmd({
|
|||
}
|
||||
|
||||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_UNBAN, user.id);
|
||||
const config = pluginData.config.get();
|
||||
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
||||
if (!reason && config.require_reason.includes("unban")) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You must include a reason in your unban");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
|
||||
|
|
|
@ -64,6 +64,10 @@ export const WarnCmd = modActionsCmd({
|
|||
|
||||
const config = pluginData.config.get();
|
||||
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
||||
if (!reason && config.require_reason.includes("warn")) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You must include a reason in your warning");
|
||||
return;
|
||||
}
|
||||
|
||||
const casesPlugin = pluginData.getPlugin(CasesPlugin);
|
||||
const priorWarnAmount = await casesPlugin.getCaseTypeAmountForUserId(memberToWarn.id, CaseTypes.Warn);
|
||||
|
|
|
@ -67,7 +67,12 @@ export async function actualKickMemberCmd(
|
|||
return;
|
||||
}
|
||||
|
||||
const config = pluginData.config.get();
|
||||
const reason = formatReasonWithAttachments(args.reason, msg.attachments);
|
||||
if (!reason && config.require_reason.includes("kick")) {
|
||||
sendErrorMessage(pluginData, msg.channel, "You must include a reason in your kick");
|
||||
return;
|
||||
}
|
||||
|
||||
const kickResult = await kickMember(pluginData, memberToKick, reason, {
|
||||
contactMethods,
|
||||
|
|
|
@ -42,7 +42,12 @@ export async function actualMuteUserCmd(
|
|||
}
|
||||
|
||||
const timeUntilUnmute = args.time && humanizeDuration(args.time);
|
||||
const config = pluginData.config.get();
|
||||
const reason = args.reason ? formatReasonWithAttachments(args.reason, [...msg.attachments.values()]) : undefined;
|
||||
if (!reason && config.require_reason.includes("mute")) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "You must include a reason in your mute");
|
||||
return;
|
||||
}
|
||||
|
||||
let muteResult: MuteResult;
|
||||
const mutesPlugin = pluginData.getPlugin(MutesPlugin);
|
||||
|
|
|
@ -27,7 +27,12 @@ export async function actualUnmuteCmd(
|
|||
pp = msg.author;
|
||||
}
|
||||
|
||||
const config = pluginData.config.get();
|
||||
const reason = args.reason ? formatReasonWithAttachments(args.reason, [...msg.attachments.values()]) : undefined;
|
||||
if (!reason && config.require_reason.includes("unmute")) {
|
||||
sendErrorMessage(pluginData, msg.channel as TextChannel, "You must include a reason in your unmute");
|
||||
return;
|
||||
}
|
||||
|
||||
const mutesPlugin = pluginData.getPlugin(MutesPlugin);
|
||||
const result = await mutesPlugin.unmuteUser(user.id, args.time, {
|
||||
|
|
|
@ -46,6 +46,7 @@ export const ConfigSchema = t.type({
|
|||
can_deletecase: t.boolean,
|
||||
can_act_as_other: t.boolean,
|
||||
create_cases_for_manual_actions: t.boolean,
|
||||
require_reason: t.array(t.string),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue