3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

added default reasons object

This commit is contained in:
iamshoXy 2023-12-29 15:40:56 +01:00
parent ac3eb74500
commit ed5214d4ec
6 changed files with 48 additions and 28 deletions

View file

@ -62,7 +62,11 @@ const defaultOptions = {
kick_message: "You have been kicked from the {guildName} server. Reason given: {reason}",
ban_message: "You have been banned from the {guildName} server. Reason given: {reason}",
tempban_message: "You have been banned from the {guildName} server for {banTime}. Reason given: {reason}",
default_ban_reason: "No reason specified",
default_reasons: {
mute: "No reason specified",
kick: "No reason specified",
ban: "No reason specified",
},
alert_on_rejoin: false,
alert_channel: null,
warn_notify_enabled: false,

View file

@ -61,7 +61,10 @@ export const ForcebanCmd = modActionsCmd({
mod = args.mod;
}
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
const config = pluginData.config.get();
const reason = args.reason
? formatReasonWithAttachments(args.reason, [...msg.attachments.values()])
: config.default_reasons?.ban || "No reason specified";
ignoreEvent(pluginData, IgnoredEventType.Ban, user.id);
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id);

View file

@ -67,7 +67,10 @@ export async function actualKickMemberCmd(
return;
}
const reason = formatReasonWithAttachments(args.reason, msg.attachments);
const config = pluginData.config.get();
const reason = args.reason
? formatReasonWithAttachments(args.reason, msg.attachments)
: config.default_reasons?.kick || "No reason specified";
const kickResult = await kickMember(pluginData, memberToKick, reason, {
contactMethods,

View file

@ -42,7 +42,11 @@ export async function actualMuteUserCmd(
}
const timeUntilUnmute = args.time && humanizeDuration(args.time);
const reason = args.reason ? formatReasonWithAttachments(args.reason, [...msg.attachments.values()]) : undefined;
const config = pluginData.config.get();
const reason = args.reason
? formatReasonWithAttachments(args.reason, [...msg.attachments.values()])
: config.default_reasons?.mute || "No reason specified";
let muteResult: MuteResult;
const mutesPlugin = pluginData.getPlugin(MutesPlugin);

View file

@ -33,7 +33,6 @@ export async function banUserId(
banOptions: BanOptions = {},
banTime?: number,
): Promise<BanResult> {
const config = pluginData.config.get();
const user = await resolveUser(pluginData.client, userId);
if (!user.id) {
return {
@ -42,7 +41,8 @@ export async function banUserId(
};
}
reason = reason || (config.default_ban_reason || "No reason specified");
const config = pluginData.config.get();
reason ||= config.default_reasons?.ban || "No reason specified";
// Attempt to message the user *before* banning them, as doing it after may not be possible
const member = await resolveMember(pluginData.client, pluginData.guild, userId);

View file

@ -23,7 +23,13 @@ export const ConfigSchema = t.type({
kick_message: tNullable(t.string),
ban_message: tNullable(t.string),
tempban_message: tNullable(t.string),
default_ban_reason: tNullable(t.string),
default_reasons: tNullable(
t.type({
mute: t.string,
kick: t.string,
ban: t.string,
}),
),
alert_on_rejoin: t.boolean,
alert_channel: tNullable(t.string),
warn_notify_enabled: t.boolean,
@ -92,36 +98,36 @@ export interface IIgnoredEvent {
export type WarnResult =
| {
status: "failed";
error: string;
}
status: "failed";
error: string;
}
| {
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
export type KickResult =
| {
status: "failed";
error: string;
}
status: "failed";
error: string;
}
| {
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
export type BanResult =
| {
status: "failed";
error: string;
}
status: "failed";
error: string;
}
| {
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
status: "success";
case: Case;
notifyResult: UserNotificationResult;
};
export type WarnMemberNotifyRetryCallback = () => boolean | Promise<boolean>;