3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-17 15:15:02 +00:00
This commit is contained in:
iamshoXy 2023-09-09 15:15:02 +02:00
parent b30b81c4ed
commit 0612b6f17d
7 changed files with 58 additions and 49 deletions

View file

@ -35,7 +35,7 @@ const caseData = z.object({
is_hidden: z.boolean(), is_hidden: z.boolean(),
pp_id: z.nullable(z.string()), pp_id: z.nullable(z.string()),
pp_name: z.nullable(z.string()), pp_name: z.nullable(z.string()),
log_message_id: z.string().optional(),
notes: z.array(caseNoteData), notes: z.array(caseNoteData),
}); });
@ -75,8 +75,7 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
try { try {
data = importExportData.parse(req.body.data); data = importExportData.parse(req.body.data);
} catch (err) { } catch (err) {
const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${ const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${err.issues[0].received
err.issues[0].received
} at /${err.issues[0].path.join("/")}`; } at /${err.issues[0].path.join("/")}`;
return clientError(res, `Invalid import data format: ${prettyMessage}`); return clientError(res, `Invalid import data format: ${prettyMessage}`);
return; return;
@ -168,7 +167,7 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
is_hidden: theCase.is_hidden, is_hidden: theCase.is_hidden,
pp_id: theCase.pp_id, pp_id: theCase.pp_id,
pp_name: theCase.pp_name, pp_name: theCase.pp_name,
log_message_id: theCase.log_message_id ?? undefined,
notes: theCase.notes.map((note) => ({ notes: theCase.notes.map((note) => ({
mod_id: note.mod_id, mod_id: note.mod_id,
mod_name: note.mod_name, mod_name: note.mod_name,

View file

@ -2,6 +2,7 @@ import { escapeInlineCode, Snowflake } from "discord.js";
import * as t from "io-ts"; import * as t from "io-ts";
import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils"; import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
import { extname } from "path";
interface MatchResultType { interface MatchResultType {
matchedType: string; matchedType: string;
@ -33,7 +34,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
} }
for (const attachment of context.message.data.attachments) { for (const attachment of context.message.data.attachments) {
const attachmentType = attachment.url.split(".").pop()!.toLowerCase(); const attachmentType = extname(new URL(attachment.url).pathname).slice(1).toLowerCase();
const blacklist = trigger.blacklist_enabled const blacklist = trigger.blacklist_enabled
? (trigger.filetype_blacklist || []).map((_t) => _t.toLowerCase()) ? (trigger.filetype_blacklist || []).map((_t) => _t.toLowerCase())

View file

@ -3,13 +3,13 @@ import { CaseTypes } from "../../data/CaseTypes";
// These emoji icons are hosted on the Hangar server // These emoji icons are hosted on the Hangar server
// If you'd like your self-hosted instance to use these icons, check #add-your-bot on that server // If you'd like your self-hosted instance to use these icons, check #add-your-bot on that server
export const caseIcons: Record<CaseTypes, string> = { export const caseIcons: Record<CaseTypes, string> = {
[CaseTypes.Ban]: "<:case_ban:906897178176393246>", [CaseTypes.Ban]: "<:case_ban:1150055546922213436>",
[CaseTypes.Unban]: "<:case_unban:906897177824067665>", [CaseTypes.Unban]: "<:case_unban:1150055555335995412>",
[CaseTypes.Note]: "<:case_note:906897177832476743>", [CaseTypes.Note]: "<:case_note:1150055552412553276>",
[CaseTypes.Warn]: "<:case_warn:906897177840844832>", [CaseTypes.Warn]: "<:case_warn:1150055557919686776>",
[CaseTypes.Kick]: "<:case_kick:906897178310639646>", [CaseTypes.Kick]: "<:case_kick:1150055557919686776>",
[CaseTypes.Mute]: "<:case_mute:906897178147057664>", [CaseTypes.Mute]: "<:case_mute:1150055557919686776>",
[CaseTypes.Unmute]: "<:case_unmute:906897177819881523>", [CaseTypes.Unmute]: "<:case_unmute:1150055557919686776>",
[CaseTypes.Deleted]: "<:case_deleted:906897178209968148>", [CaseTypes.Deleted]: "<:case_deleted:1150055557919686776>",
[CaseTypes.Softban]: "<:case_softban:906897177828278274>", [CaseTypes.Softban]: "<:case_softban:1150055557919686776>",
}; };

View file

@ -62,6 +62,7 @@ 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_ban_reason: "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

@ -42,10 +42,12 @@ export async function banUserId(
}; };
} }
reason = reason || (config.default_ban_reason || "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");
@ -91,7 +93,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;
@ -149,7 +151,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 {
@ -157,7 +159,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,7 @@ export const ConfigSchema = t.type({
kick_message: tNullable(t.string), kick_message: tNullable(t.string),
ban_message: tNullable(t.string), ban_message: tNullable(t.string),
tempban_message: tNullable(t.string), tempban_message: tNullable(t.string),
default_ban_reason: tNullable(t.string),
alert_on_rejoin: t.boolean, alert_on_rejoin: t.boolean,
alert_channel: tNullable(t.string), alert_channel: tNullable(t.string),
warn_notify_enabled: t.boolean, warn_notify_enabled: t.boolean,

View file

@ -275,6 +275,7 @@ export const tEmbed = t.type({
video: tNullable( video: tNullable(
t.type({ t.type({
url: tNullable(t.string), url: tNullable(t.string),
proxy_url: tNullable(t.string),
width: tNullable(t.number), width: tNullable(t.number),
height: tNullable(t.number), height: tNullable(t.number),
}), }),
@ -298,8 +299,8 @@ export const tEmbed = t.type({
t.type({ t.type({
name: t.string, name: t.string,
url: tNullable(t.string), url: tNullable(t.string),
width: tNullable(t.number), icon_url: tNullable(t.string),
height: tNullable(t.number), proxy_icon_url: tNullable(t.string),
}), }),
), ),
}); });
@ -315,12 +316,14 @@ export const zEmbedInput = z.object({
z.object({ z.object({
text: z.string(), text: z.string(),
icon_url: z.string().optional(), icon_url: z.string().optional(),
proxy_icon_url: z.string().optional(),
}), }),
), ),
image: z.optional( image: z.optional(
z.object({ z.object({
url: z.string().optional(), url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(), width: z.number().optional(),
height: z.number().optional(), height: z.number().optional(),
}), }),
@ -329,6 +332,7 @@ export const zEmbedInput = z.object({
thumbnail: z.optional( thumbnail: z.optional(
z.object({ z.object({
url: z.string().optional(), url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(), width: z.number().optional(),
height: z.number().optional(), height: z.number().optional(),
}), }),
@ -337,6 +341,7 @@ export const zEmbedInput = z.object({
video: z.optional( video: z.optional(
z.object({ z.object({
url: z.string().optional(), url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(), width: z.number().optional(),
height: z.number().optional(), height: z.number().optional(),
}), }),
@ -364,8 +369,8 @@ export const zEmbedInput = z.object({
z.object({ z.object({
name: z.string(), name: z.string(),
url: z.string().optional(), url: z.string().optional(),
width: z.number().optional(), icon_url: z.string().optional(),
height: z.number().optional(), proxy_icon_url: z.string().optional(),
}), }),
) )
.nullable(), .nullable(),
@ -553,7 +558,7 @@ export function convertMSToDelayString(ms: number): string {
return result; return result;
} }
export function successMessage(str: string, emoji = "<:zep_check:906897402101891093>") { export function successMessage(str: string, emoji = "<:success:1150055584566087770>") {
return emoji ? `${emoji} ${str}` : str; return emoji ? `${emoji} ${str}` : str;
} }