3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-16 14:45:02 +00:00
This commit is contained in:
iamshoXy 2024-10-19 22:57:10 +04:00 committed by GitHub
commit c1032fd43b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 8 deletions

View file

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

View file

@ -61,7 +61,10 @@ export const ForcebanCmd = modActionsCmd({
mod = args.mod; 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); ignoreEvent(pluginData, IgnoredEventType.Ban, user.id);
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id); pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id);

View file

@ -67,7 +67,10 @@ export async function actualKickMemberCmd(
return; 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, { const kickResult = await kickMember(pluginData, memberToKick, reason, {
contactMethods, contactMethods,

View file

@ -42,7 +42,11 @@ export async function actualMuteUserCmd(
} }
const timeUntilUnmute = args.time && humanizeDuration(args.time); 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; let muteResult: MuteResult;
const mutesPlugin = pluginData.getPlugin(MutesPlugin); const mutesPlugin = pluginData.getPlugin(MutesPlugin);

View file

@ -33,7 +33,6 @@ export async function banUserId(
banOptions: BanOptions = {}, banOptions: BanOptions = {},
banTime?: number, banTime?: number,
): Promise<BanResult> { ): Promise<BanResult> {
const config = pluginData.config.get();
const user = await resolveUser(pluginData.client, userId); const user = await resolveUser(pluginData.client, userId);
if (!user.id) { if (!user.id) {
return { return {
@ -42,10 +41,13 @@ export async function banUserId(
}; };
} }
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 // 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); const member = await resolveMember(pluginData.client, pluginData.guild, userId);
let notifyResult: UserNotificationResult = { method: null, success: true }; let notifyResult: UserNotificationResult = { method: null, success: true };
if (reason && member) { if (member) {
const contactMethods = banOptions?.contactMethods const contactMethods = banOptions?.contactMethods
? banOptions.contactMethods ? banOptions.contactMethods
: getDefaultContactMethods(pluginData, "ban"); : getDefaultContactMethods(pluginData, "ban");
@ -113,7 +115,7 @@ export async function banUserId(
const deleteMessageDays = Math.min(7, Math.max(0, banOptions.deleteMessageDays ?? 1)); const deleteMessageDays = Math.min(7, Math.max(0, banOptions.deleteMessageDays ?? 1));
await pluginData.guild.bans.create(userId as Snowflake, { await pluginData.guild.bans.create(userId as Snowflake, {
deleteMessageSeconds: (deleteMessageDays * DAYS) / SECONDS, deleteMessageSeconds: (deleteMessageDays * DAYS) / SECONDS,
reason: reason ?? undefined, reason,
}); });
} catch (e) { } catch (e) {
let errorMessage; let errorMessage;
@ -171,7 +173,7 @@ export async function banUserId(
mod, mod,
user, user,
caseNumber: createdCase.case_number, caseNumber: createdCase.case_number,
reason: reason ?? "", reason,
banTime: humanizeDuration(banTime), banTime: humanizeDuration(banTime),
}); });
} else { } else {
@ -179,7 +181,7 @@ export async function banUserId(
mod, mod,
user, user,
caseNumber: createdCase.case_number, caseNumber: createdCase.case_number,
reason: reason ?? "", reason,
}); });
} }

View file

@ -23,6 +23,13 @@ export const zModActionsConfig = z.strictObject({
kick_message: z.nullable(z.string()), kick_message: z.nullable(z.string()),
ban_message: z.nullable(z.string()), ban_message: z.nullable(z.string()),
tempban_message: z.nullable(z.string()), tempban_message: z.nullable(z.string()),
default_reasons: z.nullable(
z.object({
mute: z.string().max(512).nullable(),
kick: z.string().max(512).nullable(),
ban: z.string().max(512).nullable(),
}),
),
alert_on_rejoin: z.boolean(), alert_on_rejoin: z.boolean(),
alert_channel: z.nullable(z.string()), alert_channel: z.nullable(z.string()),
warn_notify_enabled: z.boolean(), warn_notify_enabled: z.boolean(),