mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 07:05:03 +00:00
Update
This commit is contained in:
parent
b30b81c4ed
commit
0612b6f17d
7 changed files with 58 additions and 49 deletions
|
@ -35,7 +35,7 @@ const caseData = z.object({
|
|||
is_hidden: z.boolean(),
|
||||
pp_id: z.nullable(z.string()),
|
||||
pp_name: z.nullable(z.string()),
|
||||
|
||||
log_message_id: z.string().optional(),
|
||||
notes: z.array(caseNoteData),
|
||||
});
|
||||
|
||||
|
@ -75,8 +75,7 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
|||
try {
|
||||
data = importExportData.parse(req.body.data);
|
||||
} catch (err) {
|
||||
const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${
|
||||
err.issues[0].received
|
||||
const prettyMessage = `${err.issues[0].code}: expected ${err.issues[0].expected}, received ${err.issues[0].received
|
||||
} at /${err.issues[0].path.join("/")}`;
|
||||
return clientError(res, `Invalid import data format: ${prettyMessage}`);
|
||||
return;
|
||||
|
@ -168,7 +167,7 @@ export function initGuildsImportExportAPI(guildRouter: express.Router) {
|
|||
is_hidden: theCase.is_hidden,
|
||||
pp_id: theCase.pp_id,
|
||||
pp_name: theCase.pp_name,
|
||||
|
||||
log_message_id: theCase.log_message_id ?? undefined,
|
||||
notes: theCase.notes.map((note) => ({
|
||||
mod_id: note.mod_id,
|
||||
mod_name: note.mod_name,
|
||||
|
|
|
@ -2,6 +2,7 @@ import { escapeInlineCode, Snowflake } from "discord.js";
|
|||
import * as t from "io-ts";
|
||||
import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils";
|
||||
import { automodTrigger } from "../helpers";
|
||||
import { extname } from "path";
|
||||
|
||||
interface MatchResultType {
|
||||
matchedType: string;
|
||||
|
@ -33,7 +34,7 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
|
|||
}
|
||||
|
||||
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
|
||||
? (trigger.filetype_blacklist || []).map((_t) => _t.toLowerCase())
|
||||
|
|
|
@ -3,13 +3,13 @@ import { CaseTypes } from "../../data/CaseTypes";
|
|||
// 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
|
||||
export const caseIcons: Record<CaseTypes, string> = {
|
||||
[CaseTypes.Ban]: "<:case_ban:906897178176393246>",
|
||||
[CaseTypes.Unban]: "<:case_unban:906897177824067665>",
|
||||
[CaseTypes.Note]: "<:case_note:906897177832476743>",
|
||||
[CaseTypes.Warn]: "<:case_warn:906897177840844832>",
|
||||
[CaseTypes.Kick]: "<:case_kick:906897178310639646>",
|
||||
[CaseTypes.Mute]: "<:case_mute:906897178147057664>",
|
||||
[CaseTypes.Unmute]: "<:case_unmute:906897177819881523>",
|
||||
[CaseTypes.Deleted]: "<:case_deleted:906897178209968148>",
|
||||
[CaseTypes.Softban]: "<:case_softban:906897177828278274>",
|
||||
[CaseTypes.Ban]: "<:case_ban:1150055546922213436>",
|
||||
[CaseTypes.Unban]: "<:case_unban:1150055555335995412>",
|
||||
[CaseTypes.Note]: "<:case_note:1150055552412553276>",
|
||||
[CaseTypes.Warn]: "<:case_warn:1150055557919686776>",
|
||||
[CaseTypes.Kick]: "<:case_kick:1150055557919686776>",
|
||||
[CaseTypes.Mute]: "<:case_mute:1150055557919686776>",
|
||||
[CaseTypes.Unmute]: "<:case_unmute:1150055557919686776>",
|
||||
[CaseTypes.Deleted]: "<:case_deleted:1150055557919686776>",
|
||||
[CaseTypes.Softban]: "<:case_softban:1150055557919686776>",
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ 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",
|
||||
alert_on_rejoin: false,
|
||||
alert_channel: null,
|
||||
warn_notify_enabled: false,
|
||||
|
|
|
@ -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
|
||||
const member = await resolveMember(pluginData.client, pluginData.guild, userId);
|
||||
let notifyResult: UserNotificationResult = { method: null, success: true };
|
||||
if (reason && member) {
|
||||
if (member) {
|
||||
const contactMethods = banOptions?.contactMethods
|
||||
? banOptions.contactMethods
|
||||
: getDefaultContactMethods(pluginData, "ban");
|
||||
|
@ -91,7 +93,7 @@ export async function banUserId(
|
|||
const deleteMessageDays = Math.min(7, Math.max(0, banOptions.deleteMessageDays ?? 1));
|
||||
await pluginData.guild.bans.create(userId as Snowflake, {
|
||||
deleteMessageSeconds: (deleteMessageDays * DAYS) / SECONDS,
|
||||
reason: reason ?? undefined,
|
||||
reason,
|
||||
});
|
||||
} catch (e) {
|
||||
let errorMessage;
|
||||
|
@ -149,7 +151,7 @@ export async function banUserId(
|
|||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
reason,
|
||||
banTime: humanizeDuration(banTime),
|
||||
});
|
||||
} else {
|
||||
|
@ -157,7 +159,7 @@ export async function banUserId(
|
|||
mod,
|
||||
user,
|
||||
caseNumber: createdCase.case_number,
|
||||
reason: reason ?? "",
|
||||
reason,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ 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),
|
||||
alert_on_rejoin: t.boolean,
|
||||
alert_channel: tNullable(t.string),
|
||||
warn_notify_enabled: t.boolean,
|
||||
|
|
|
@ -135,7 +135,7 @@ export interface TDeepPartialProps<P extends t.Props>
|
|||
{
|
||||
[K in keyof P]?: TDeepPartial<t.OutputOf<P[K]>>;
|
||||
}
|
||||
> {}
|
||||
> { }
|
||||
|
||||
export function tDeepPartial<T>(type: T): TDeepPartial<T> {
|
||||
if (type instanceof t.InterfaceType || type instanceof t.PartialType) {
|
||||
|
@ -220,7 +220,7 @@ export interface PartialDictionaryC<D extends t.Mixed, C extends t.Mixed>
|
|||
[K in t.OutputOf<D>]?: t.OutputOf<C>;
|
||||
},
|
||||
unknown
|
||||
> {}
|
||||
> { }
|
||||
|
||||
export const tPartialDictionary = <D extends t.Mixed, C extends t.Mixed>(
|
||||
domain: D,
|
||||
|
@ -275,6 +275,7 @@ export const tEmbed = t.type({
|
|||
video: tNullable(
|
||||
t.type({
|
||||
url: tNullable(t.string),
|
||||
proxy_url: tNullable(t.string),
|
||||
width: tNullable(t.number),
|
||||
height: tNullable(t.number),
|
||||
}),
|
||||
|
@ -298,8 +299,8 @@ export const tEmbed = t.type({
|
|||
t.type({
|
||||
name: t.string,
|
||||
url: tNullable(t.string),
|
||||
width: tNullable(t.number),
|
||||
height: tNullable(t.number),
|
||||
icon_url: tNullable(t.string),
|
||||
proxy_icon_url: tNullable(t.string),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
@ -315,12 +316,14 @@ export const zEmbedInput = z.object({
|
|||
z.object({
|
||||
text: z.string(),
|
||||
icon_url: z.string().optional(),
|
||||
proxy_icon_url: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
|
||||
image: z.optional(
|
||||
z.object({
|
||||
url: z.string().optional(),
|
||||
proxy_url: z.string().optional(),
|
||||
width: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
}),
|
||||
|
@ -329,6 +332,7 @@ export const zEmbedInput = z.object({
|
|||
thumbnail: z.optional(
|
||||
z.object({
|
||||
url: z.string().optional(),
|
||||
proxy_url: z.string().optional(),
|
||||
width: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
}),
|
||||
|
@ -337,6 +341,7 @@ export const zEmbedInput = z.object({
|
|||
video: z.optional(
|
||||
z.object({
|
||||
url: z.string().optional(),
|
||||
proxy_url: z.string().optional(),
|
||||
width: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
}),
|
||||
|
@ -364,8 +369,8 @@ export const zEmbedInput = z.object({
|
|||
z.object({
|
||||
name: z.string(),
|
||||
url: z.string().optional(),
|
||||
width: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
icon_url: z.string().optional(),
|
||||
proxy_icon_url: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.nullable(),
|
||||
|
@ -553,7 +558,7 @@ export function convertMSToDelayString(ms: number): string {
|
|||
return result;
|
||||
}
|
||||
|
||||
export function successMessage(str: string, emoji = "<:zep_check:906897402101891093>") {
|
||||
export function successMessage(str: string, emoji = "<:success:1150055584566087770>") {
|
||||
return emoji ? `${emoji} ${str}` : str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue