mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-06 10:37:19 +00:00
chore: run formatter
This commit is contained in:
parent
3ef89246ba
commit
3722393ec0
40 changed files with 13085 additions and 13040 deletions
|
@ -9,7 +9,10 @@ const isTimeoutError = (a): a is TimeoutError => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class RegExpTimeoutError extends Error {
|
export class RegExpTimeoutError extends Error {
|
||||||
constructor(message: string, public elapsedTimeMs: number) {
|
constructor(
|
||||||
|
message: string,
|
||||||
|
public elapsedTimeMs: number,
|
||||||
|
) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import z from "zod/v4";
|
import z from "zod/v4";
|
||||||
|
import { $ZodPipeDef } from "zod/v4/core";
|
||||||
import { availableGuildPlugins } from "../plugins/availablePlugins.js";
|
import { availableGuildPlugins } from "../plugins/availablePlugins.js";
|
||||||
import { ZeppelinGuildPluginInfo } from "../types.js";
|
import { ZeppelinGuildPluginInfo } from "../types.js";
|
||||||
import { indentLines } from "../utils.js";
|
import { indentLines } from "../utils.js";
|
||||||
import { notFound } from "./responses.js";
|
import { notFound } from "./responses.js";
|
||||||
import { $ZodPipeDef } from "zod/v4/core";
|
|
||||||
|
|
||||||
function isZodObject(schema: z.ZodType): schema is z.ZodObject<any> {
|
function isZodObject(schema: z.ZodType): schema is z.ZodObject<any> {
|
||||||
return schema.def.type === "object";
|
return schema.def.type === "object";
|
||||||
|
|
|
@ -28,15 +28,12 @@ export async function validateGuildConfig(config: any): Promise<string | null> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const plugin = pluginNameToPlugin.get(pluginName)!;
|
const plugin = pluginNameToPlugin.get(pluginName)!;
|
||||||
const configManager = new PluginConfigManager(
|
const configManager = new PluginConfigManager(pluginOptions, {
|
||||||
pluginOptions,
|
configSchema: plugin.configSchema,
|
||||||
{
|
defaultOverrides: plugin.defaultOverrides ?? [],
|
||||||
configSchema: plugin.configSchema,
|
levels: {},
|
||||||
defaultOverrides: plugin.defaultOverrides ?? [],
|
customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions,
|
||||||
levels: {},
|
});
|
||||||
customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configManager.init();
|
await configManager.init();
|
||||||
|
|
|
@ -59,9 +59,12 @@ async function getSessionToken(): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeUntilExpiry = Date.now() - parseResult.data.expires * 1000;
|
const timeUntilExpiry = Date.now() - parseResult.data.expires * 1000;
|
||||||
setTimeout(() => {
|
setTimeout(
|
||||||
sessionTokenPromise = null;
|
() => {
|
||||||
}, timeUntilExpiry - 1 * MINUTES); // Subtract a minute to ensure we refresh before expiry
|
sessionTokenPromise = null;
|
||||||
|
},
|
||||||
|
timeUntilExpiry - 1 * MINUTES,
|
||||||
|
); // Subtract a minute to ensure we refresh before expiry
|
||||||
|
|
||||||
return parseResult.data.token;
|
return parseResult.data.token;
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -40,9 +40,12 @@ export class GuildLogs extends events.EventEmitter {
|
||||||
this.ignoredLogs.push({ type, ignoreId });
|
this.ignoredLogs.push({ type, ignoreId });
|
||||||
|
|
||||||
// Clear after expiry (15sec by default)
|
// Clear after expiry (15sec by default)
|
||||||
setTimeout(() => {
|
setTimeout(
|
||||||
this.clearIgnoredLog(type, ignoreId);
|
() => {
|
||||||
}, timeout || 1000 * 15);
|
this.clearIgnoredLog(type, ignoreId);
|
||||||
|
},
|
||||||
|
timeout || 1000 * 15,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
isLogIgnored(type: keyof typeof LogType, ignoreId: any) {
|
isLogIgnored(type: keyof typeof LogType, ignoreId: any) {
|
||||||
|
|
|
@ -34,22 +34,24 @@ const basePluginOverrideCriteriaSchema = z.strictObject({
|
||||||
extra: z.any().optional(),
|
extra: z.any().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema.extend({
|
const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema
|
||||||
get zzz_dummy_property_do_not_use() {
|
.extend({
|
||||||
return pluginOverrideCriteriaSchema.optional();
|
get zzz_dummy_property_do_not_use() {
|
||||||
},
|
return pluginOverrideCriteriaSchema.optional();
|
||||||
get all() {
|
},
|
||||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
get all() {
|
||||||
},
|
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||||
get any() {
|
},
|
||||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
get any() {
|
||||||
},
|
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||||
get not() {
|
},
|
||||||
return pluginOverrideCriteriaSchema.optional();
|
get not() {
|
||||||
},
|
return pluginOverrideCriteriaSchema.optional();
|
||||||
}).meta({
|
},
|
||||||
id: "overrideCriteria",
|
})
|
||||||
});
|
.meta({
|
||||||
|
id: "overrideCriteria",
|
||||||
|
});
|
||||||
|
|
||||||
const outputPath = process.argv[2];
|
const outputPath = process.argv[2];
|
||||||
if (!outputPath) {
|
if (!outputPath) {
|
||||||
|
|
|
@ -199,14 +199,17 @@ setInterval(() => {
|
||||||
avgCount++;
|
avgCount++;
|
||||||
lastCheck = now;
|
lastCheck = now;
|
||||||
}, 500);
|
}, 500);
|
||||||
setInterval(() => {
|
setInterval(
|
||||||
const avgBlocking = avgTotal / (avgCount || 1);
|
() => {
|
||||||
// FIXME: Debug
|
const avgBlocking = avgTotal / (avgCount || 1);
|
||||||
// tslint:disable-next-line:no-console
|
// FIXME: Debug
|
||||||
console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`);
|
// tslint:disable-next-line:no-console
|
||||||
avgTotal = 0;
|
console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`);
|
||||||
avgCount = 0;
|
avgTotal = 0;
|
||||||
}, 5 * 60 * 1000);
|
avgCount = 0;
|
||||||
|
},
|
||||||
|
5 * 60 * 1000,
|
||||||
|
);
|
||||||
|
|
||||||
if (env.DEBUG) {
|
if (env.DEBUG) {
|
||||||
logger.info("NOTE: Bot started in DEBUG mode");
|
logger.info("NOTE: Bot started in DEBUG mode");
|
||||||
|
@ -332,7 +335,7 @@ connect().then(async () => {
|
||||||
|
|
||||||
if (loaded.success_emoji || loaded.error_emoji) {
|
if (loaded.success_emoji || loaded.error_emoji) {
|
||||||
const deprecatedKeys = [] as string[];
|
const deprecatedKeys = [] as string[];
|
||||||
const exampleConfig = `plugins:\n common:\n config:\n success_emoji: "👍"\n error_emoji: "👎"`;
|
// const exampleConfig = `plugins:\n common:\n config:\n success_emoji: "👍"\n error_emoji: "👎"`;
|
||||||
|
|
||||||
if (loaded.success_emoji) {
|
if (loaded.success_emoji) {
|
||||||
deprecatedKeys.push("success_emoji");
|
deprecatedKeys.push("success_emoji");
|
||||||
|
|
|
@ -65,10 +65,13 @@ const permissionNames = keys(PermissionsBitField.Flags) as U.ListOf<keyof typeof
|
||||||
const legacyPermissionNames = keys(legacyPermMap) as U.ListOf<keyof typeof legacyPermMap>;
|
const legacyPermissionNames = keys(legacyPermMap) as U.ListOf<keyof typeof legacyPermMap>;
|
||||||
const allPermissionNames = [...permissionNames, ...legacyPermissionNames] as const;
|
const allPermissionNames = [...permissionNames, ...legacyPermissionNames] as const;
|
||||||
|
|
||||||
const permissionTypeMap = allPermissionNames.reduce((map, permName) => {
|
const permissionTypeMap = allPermissionNames.reduce(
|
||||||
map[permName] = z.boolean().nullable();
|
(map, permName) => {
|
||||||
return map;
|
map[permName] = z.boolean().nullable();
|
||||||
}, {} as Record<typeof allPermissionNames[number], z.ZodNullable<z.ZodBoolean>>);
|
return map;
|
||||||
|
},
|
||||||
|
{} as Record<(typeof allPermissionNames)[number], z.ZodNullable<z.ZodBoolean>>,
|
||||||
|
);
|
||||||
const zPermissionsMap = z.strictObject(permissionTypeMap);
|
const zPermissionsMap = z.strictObject(permissionTypeMap);
|
||||||
|
|
||||||
export const ChangePermsAction = automodAction({
|
export const ChangePermsAction = automodAction({
|
||||||
|
|
|
@ -15,8 +15,16 @@ const configSchema = z.strictObject({
|
||||||
exclude_guilds: z.array(zSnowflake).max(255).optional(),
|
exclude_guilds: z.array(zSnowflake).max(255).optional(),
|
||||||
include_invite_codes: z.array(z.string().max(32)).max(255).optional(),
|
include_invite_codes: z.array(z.string().max(32)).max(255).optional(),
|
||||||
exclude_invite_codes: z.array(z.string().max(32)).max(255).optional(),
|
exclude_invite_codes: z.array(z.string().max(32)).max(255).optional(),
|
||||||
include_custom_invite_codes: z.array(z.string().max(32)).max(255).transform(arr => arr.map(str => str.toLowerCase())).optional(),
|
include_custom_invite_codes: z
|
||||||
exclude_custom_invite_codes: z.array(z.string().max(32)).max(255).transform(arr => arr.map(str => str.toLowerCase())).optional(),
|
.array(z.string().max(32))
|
||||||
|
.max(255)
|
||||||
|
.transform((arr) => arr.map((str) => str.toLowerCase()))
|
||||||
|
.optional(),
|
||||||
|
exclude_custom_invite_codes: z
|
||||||
|
.array(z.string().max(32))
|
||||||
|
.max(255)
|
||||||
|
.transform((arr) => arr.map((str) => str.toLowerCase()))
|
||||||
|
.optional(),
|
||||||
allow_group_dm_invites: z.boolean().default(false),
|
allow_group_dm_invites: z.boolean().default(false),
|
||||||
match_messages: z.boolean().default(true),
|
match_messages: z.boolean().default(true),
|
||||||
match_embeds: z.boolean().default(false),
|
match_embeds: z.boolean().default(false),
|
||||||
|
|
|
@ -73,7 +73,10 @@ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
||||||
|
|
||||||
if (trigger.exclude_regex) {
|
if (trigger.exclude_regex) {
|
||||||
if (!regexCache.has(trigger.exclude_regex)) {
|
if (!regexCache.has(trigger.exclude_regex)) {
|
||||||
const toCache = mergeRegexes(trigger.exclude_regex.map(pattern => inputPatternToRegExp(pattern)), "i");
|
const toCache = mergeRegexes(
|
||||||
|
trigger.exclude_regex.map((pattern) => inputPatternToRegExp(pattern)),
|
||||||
|
"i",
|
||||||
|
);
|
||||||
regexCache.set(trigger.exclude_regex, toCache);
|
regexCache.set(trigger.exclude_regex, toCache);
|
||||||
}
|
}
|
||||||
const regexes = regexCache.get(trigger.exclude_regex)!;
|
const regexes = regexCache.get(trigger.exclude_regex)!;
|
||||||
|
@ -88,7 +91,10 @@ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
||||||
|
|
||||||
if (trigger.include_regex) {
|
if (trigger.include_regex) {
|
||||||
if (!regexCache.has(trigger.include_regex)) {
|
if (!regexCache.has(trigger.include_regex)) {
|
||||||
const toCache = mergeRegexes(trigger.include_regex.map(pattern => inputPatternToRegExp(pattern)), "i");
|
const toCache = mergeRegexes(
|
||||||
|
trigger.include_regex.map((pattern) => inputPatternToRegExp(pattern)),
|
||||||
|
"i",
|
||||||
|
);
|
||||||
regexCache.set(trigger.include_regex, toCache);
|
regexCache.set(trigger.include_regex, toCache);
|
||||||
}
|
}
|
||||||
const regexes = regexCache.get(trigger.include_regex)!;
|
const regexes = regexCache.get(trigger.include_regex)!;
|
||||||
|
|
|
@ -38,7 +38,10 @@ export const MatchRegexTrigger = automodTrigger<MatchResultType>()({
|
||||||
|
|
||||||
if (!regexCache.has(trigger)) {
|
if (!regexCache.has(trigger)) {
|
||||||
const flags = trigger.case_sensitive ? "" : "i";
|
const flags = trigger.case_sensitive ? "" : "i";
|
||||||
const toCache = mergeRegexes(trigger.patterns.map(pattern => inputPatternToRegExp(pattern)), flags);
|
const toCache = mergeRegexes(
|
||||||
|
trigger.patterns.map((pattern) => inputPatternToRegExp(pattern)),
|
||||||
|
flags,
|
||||||
|
);
|
||||||
regexCache.set(trigger, toCache);
|
regexCache.set(trigger, toCache);
|
||||||
}
|
}
|
||||||
const regexes = regexCache.get(trigger)!;
|
const regexes = regexCache.get(trigger)!;
|
||||||
|
|
|
@ -44,9 +44,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||||
let pattern;
|
let pattern;
|
||||||
|
|
||||||
if (trigger.loose_matching) {
|
if (trigger.loose_matching) {
|
||||||
pattern = [...word]
|
pattern = [...word].map((c) => escapeStringRegexp(c)).join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`);
|
||||||
.map((c) => escapeStringRegexp(c))
|
|
||||||
.join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`);
|
|
||||||
} else {
|
} else {
|
||||||
pattern = escapeStringRegexp(word);
|
pattern = escapeStringRegexp(word);
|
||||||
}
|
}
|
||||||
|
@ -62,10 +60,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||||
return pattern;
|
return pattern;
|
||||||
});
|
});
|
||||||
|
|
||||||
const mergedRegex = new RegExp(
|
const mergedRegex = new RegExp(patterns.map((p) => `(${p})`).join("|"), trigger.case_sensitive ? "" : "i");
|
||||||
patterns.map((p) => `(${p})`).join("|"),
|
|
||||||
trigger.case_sensitive ? "" : "i"
|
|
||||||
);
|
|
||||||
|
|
||||||
regexCache.set(trigger, [mergedRegex]);
|
regexCache.set(trigger, [mergedRegex]);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +79,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||||
for (const regex of regexes) {
|
for (const regex of regexes) {
|
||||||
const match = regex.exec(str);
|
const match = regex.exec(str);
|
||||||
if (match) {
|
if (match) {
|
||||||
const matchedWordIndex = match.slice(1).findIndex(group => group !== undefined);
|
const matchedWordIndex = match.slice(1).findIndex((group) => group !== undefined);
|
||||||
const matchedWord = trigger.words[matchedWordIndex];
|
const matchedWord = trigger.words[matchedWordIndex];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { GuildPluginData } from "knub";
|
||||||
import { splitMessageIntoChunks } from "knub/helpers";
|
import { splitMessageIntoChunks } from "knub/helpers";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { Case } from "../../../data/entities/Case.js";
|
import { Case } from "../../../data/entities/Case.js";
|
||||||
import { convertDelayStringToMS, DBDateFormat, disableLinkPreviews, messageLink } from "../../../utils.js";
|
import { convertDelayStringToMS, DBDateFormat, messageLink } from "../../../utils.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { caseAbbreviations } from "../caseAbbreviations.js";
|
import { caseAbbreviations } from "../caseAbbreviations.js";
|
||||||
import { CasesPluginType } from "../types.js";
|
import { CasesPluginType } from "../types.js";
|
||||||
|
|
|
@ -10,15 +10,21 @@ import { zColor } from "../../utils/zColor.js";
|
||||||
|
|
||||||
const caseKeys = keys(CaseNameToType) as U.ListOf<keyof typeof CaseNameToType>;
|
const caseKeys = keys(CaseNameToType) as U.ListOf<keyof typeof CaseNameToType>;
|
||||||
|
|
||||||
const caseColorsTypeMap = caseKeys.reduce((map, key) => {
|
const caseColorsTypeMap = caseKeys.reduce(
|
||||||
map[key] = zColor;
|
(map, key) => {
|
||||||
return map;
|
map[key] = zColor;
|
||||||
}, {} as Record<typeof caseKeys[number], typeof zColor>);
|
return map;
|
||||||
|
},
|
||||||
|
{} as Record<(typeof caseKeys)[number], typeof zColor>,
|
||||||
|
);
|
||||||
|
|
||||||
const caseIconsTypeMap = caseKeys.reduce((map, key) => {
|
const caseIconsTypeMap = caseKeys.reduce(
|
||||||
map[key] = zBoundedCharacters(0, 100);
|
(map, key) => {
|
||||||
return map;
|
map[key] = zBoundedCharacters(0, 100);
|
||||||
}, {} as Record<typeof caseKeys[number], z.ZodString>);
|
return map;
|
||||||
|
},
|
||||||
|
{} as Record<(typeof caseKeys)[number], z.ZodString>,
|
||||||
|
);
|
||||||
|
|
||||||
export const zCasesConfig = z.strictObject({
|
export const zCasesConfig = z.strictObject({
|
||||||
log_automatic_actions: z.boolean().default(true),
|
log_automatic_actions: z.boolean().default(true),
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const CommonPlugin = guildPlugin<CommonPluginType>()({
|
||||||
storeAttachmentsAsMessage: async (attachments: Attachment[], backupChannel?: TextBasedChannel | null) => {
|
storeAttachmentsAsMessage: async (attachments: Attachment[], backupChannel?: TextBasedChannel | null) => {
|
||||||
const attachmentChannelId = pluginData.config.get().attachment_storing_channel;
|
const attachmentChannelId = pluginData.config.get().attachment_storing_channel;
|
||||||
const channel = attachmentChannelId
|
const channel = attachmentChannelId
|
||||||
? (pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel
|
? ((pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel)
|
||||||
: backupChannel;
|
: backupChannel;
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CommonPluginType } from "../types.js";
|
|
||||||
import { env } from "../../../env.js";
|
import { env } from "../../../env.js";
|
||||||
|
import { CommonPluginType } from "../types.js";
|
||||||
|
|
||||||
export function getSuccessEmoji(pluginData: GuildPluginData<CommonPluginType>) {
|
export function getSuccessEmoji(pluginData: GuildPluginData<CommonPluginType>) {
|
||||||
return pluginData.config.get().success_emoji ?? env.DEFAULT_SUCCESS_EMOJI;
|
return pluginData.config.get().success_emoji ?? env.DEFAULT_SUCCESS_EMOJI;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js";
|
||||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||||
import { LogType } from "../../data/LogType.js";
|
import { LogType } from "../../data/LogType.js";
|
||||||
import { keys, zBoundedCharacters, zEmbedInput, zMessageContent, zRegex, zSnowflake, zStrictMessageContent } from "../../utils.js";
|
import { keys, zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js";
|
||||||
import { MessageBuffer } from "../../utils/MessageBuffer.js";
|
import { MessageBuffer } from "../../utils/MessageBuffer.js";
|
||||||
import {
|
import {
|
||||||
TemplateSafeCase,
|
TemplateSafeCase,
|
||||||
|
@ -30,10 +30,13 @@ const MAX_BATCH_TIME = 5000;
|
||||||
// A bit of a workaround so we can pass LogType keys to z.enum()
|
// A bit of a workaround so we can pass LogType keys to z.enum()
|
||||||
const zMessageContentWithDefault = zMessageContent.default("");
|
const zMessageContentWithDefault = zMessageContent.default("");
|
||||||
const logTypes = keys(LogType);
|
const logTypes = keys(LogType);
|
||||||
const logTypeProps = logTypes.reduce((map, type) => {
|
const logTypeProps = logTypes.reduce(
|
||||||
map[type] = zMessageContent.default(DefaultLogMessages[type] || "");
|
(map, type) => {
|
||||||
return map;
|
map[type] = zMessageContent.default(DefaultLogMessages[type] || "");
|
||||||
}, {} as Record<keyof typeof LogType, typeof zMessageContentWithDefault>);
|
return map;
|
||||||
|
},
|
||||||
|
{} as Record<keyof typeof LogType, typeof zMessageContentWithDefault>,
|
||||||
|
);
|
||||||
const zLogFormats = z.strictObject(logTypeProps);
|
const zLogFormats = z.strictObject(logTypeProps);
|
||||||
|
|
||||||
const zLogChannel = z.strictObject({
|
const zLogChannel = z.strictObject({
|
||||||
|
|
|
@ -77,7 +77,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
||||||
[...msg.attachments.values()],
|
[...msg.attachments.values()],
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
"time" in args ? args.time ?? undefined : undefined,
|
"time" in args ? (args.time ?? undefined) : undefined,
|
||||||
args.reason,
|
args.reason,
|
||||||
contactMethods,
|
contactMethods,
|
||||||
);
|
);
|
||||||
|
|
|
@ -68,7 +68,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -72,7 +72,7 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
||||||
[...msg.attachments.values()],
|
[...msg.attachments.values()],
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
"time" in args ? args.time ?? undefined : undefined,
|
"time" in args ? (args.time ?? undefined) : undefined,
|
||||||
args.reason,
|
args.reason,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,7 +52,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -103,7 +103,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
||||||
[...msg.attachments.values()],
|
[...msg.attachments.values()],
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
"time" in args ? args.time ?? undefined : undefined,
|
"time" in args ? (args.time ?? undefined) : undefined,
|
||||||
args.reason,
|
args.reason,
|
||||||
contactMethods,
|
contactMethods,
|
||||||
);
|
);
|
||||||
|
|
|
@ -95,7 +95,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -105,7 +105,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
||||||
[...msg.attachments.values()],
|
[...msg.attachments.values()],
|
||||||
mod,
|
mod,
|
||||||
ppId,
|
ppId,
|
||||||
"time" in args ? args.time ?? undefined : undefined,
|
"time" in args ? (args.time ?? undefined) : undefined,
|
||||||
args.reason,
|
args.reason,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -99,7 +99,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
||||||
ppId = interaction.user.id;
|
ppId = interaction.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined;
|
const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined;
|
||||||
if (options.time && !convertedTime) {
|
if (options.time && !convertedTime) {
|
||||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -186,8 +186,8 @@ export async function muteUser(
|
||||||
const template = existingMute
|
const template = existingMute
|
||||||
? config.update_mute_message
|
? config.update_mute_message
|
||||||
: muteTime
|
: muteTime
|
||||||
? config.timed_mute_message
|
? config.timed_mute_message
|
||||||
: config.mute_message;
|
: config.mute_message;
|
||||||
|
|
||||||
let muteMessage: string | null = null;
|
let muteMessage: string | null = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,5 +7,6 @@ export const zPhishermanConfig = z.strictObject({
|
||||||
|
|
||||||
export interface PhishermanPluginType extends BasePluginType {
|
export interface PhishermanPluginType extends BasePluginType {
|
||||||
configSchema: typeof zPhishermanConfig;
|
configSchema: typeof zPhishermanConfig;
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
state: {};
|
state: {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
|
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
|
||||||
import { U } from "ts-toolbelt";
|
|
||||||
import z from "zod/v4";
|
import z from "zod/v4";
|
||||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
|
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
|
||||||
import { keys } from "../../utils.js";
|
import { keys } from "../../utils.js";
|
||||||
|
@ -7,12 +6,13 @@ import { zValidTimezone } from "../../utils/zValidTimezone.js";
|
||||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||||
import { defaultDateFormats } from "./defaultDateFormats.js";
|
import { defaultDateFormats } from "./defaultDateFormats.js";
|
||||||
|
|
||||||
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);
|
const dateFormatTypeMap = keys(defaultDateFormats).reduce(
|
||||||
|
(map, key) => {
|
||||||
const dateFormatTypeMap = keys(defaultDateFormats).reduce((map, key) => {
|
map[key] = z.string().default(defaultDateFormats[key]);
|
||||||
map[key] = z.string().default(defaultDateFormats[key]);
|
return map;
|
||||||
return map;
|
},
|
||||||
}, {} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>);
|
{} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>,
|
||||||
|
);
|
||||||
|
|
||||||
export const zTimeAndDateConfig = z.strictObject({
|
export const zTimeAndDateConfig = z.strictObject({
|
||||||
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
|
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
|
||||||
|
|
|
@ -55,7 +55,7 @@ export async function fetchChannelMessagesToClean(
|
||||||
pinIds = new Set((await targetChannel.messages.fetchPinned()).keys());
|
pinIds = new Set((await targetChannel.messages.fetchPinned()).keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
let rawMessagesToClean: Array<OmitPartialGroupDMChannel<Message<true>>> = [];
|
const rawMessagesToClean: Array<OmitPartialGroupDMChannel<Message<true>>> = [];
|
||||||
let beforeId = opts.beforeId;
|
let beforeId = opts.beforeId;
|
||||||
let requests = 0;
|
let requests = 0;
|
||||||
while (rawMessagesToClean.length < opts.count) {
|
while (rawMessagesToClean.length < opts.count) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ export async function getInviteInfoEmbed(
|
||||||
pluginData: GuildPluginData<UtilityPluginType>,
|
pluginData: GuildPluginData<UtilityPluginType>,
|
||||||
inviteCode: string,
|
inviteCode: string,
|
||||||
): Promise<APIEmbed | null> {
|
): Promise<APIEmbed | null> {
|
||||||
let invite = await resolveInvite(pluginData.client, inviteCode, true);
|
const invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||||
if (!invite) {
|
if (!invite) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
APIEmbed,
|
APIEmbed,
|
||||||
ChannelType,
|
ChannelType,
|
||||||
ChatInputCommandInteraction,
|
|
||||||
Client,
|
Client,
|
||||||
DiscordAPIError,
|
DiscordAPIError,
|
||||||
EmbedData,
|
EmbedData,
|
||||||
|
@ -20,14 +19,11 @@ import {
|
||||||
Message,
|
Message,
|
||||||
MessageCreateOptions,
|
MessageCreateOptions,
|
||||||
MessageMentionOptions,
|
MessageMentionOptions,
|
||||||
PartialChannelData,
|
|
||||||
PartialGroupDMChannel,
|
PartialGroupDMChannel,
|
||||||
PartialMessage,
|
PartialMessage,
|
||||||
PartialUser,
|
|
||||||
RoleResolvable,
|
RoleResolvable,
|
||||||
SendableChannels,
|
SendableChannels,
|
||||||
Sticker,
|
Sticker,
|
||||||
TextBasedChannel,
|
|
||||||
User,
|
User,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import emojiRegex from "emoji-regex";
|
import emojiRegex from "emoji-regex";
|
||||||
|
@ -197,94 +193,99 @@ export function zRegex<T extends ZodString>(zStr: T) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const zEmbedInput = z.strictObject({
|
export const zEmbedInput = z
|
||||||
title: z.string().optional(),
|
.strictObject({
|
||||||
description: z.string().optional(),
|
title: z.string().optional(),
|
||||||
url: z.string().optional(),
|
description: z.string().optional(),
|
||||||
timestamp: z.string().optional(),
|
url: z.string().optional(),
|
||||||
color: z.number().optional(),
|
timestamp: z.string().optional(),
|
||||||
|
color: z.number().optional(),
|
||||||
|
|
||||||
footer: z.optional(
|
footer: z.optional(
|
||||||
z.object({
|
|
||||||
text: z.string(),
|
|
||||||
icon_url: z.string().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
image: z.optional(
|
|
||||||
z.object({
|
|
||||||
url: z.string().optional(),
|
|
||||||
width: z.number().optional(),
|
|
||||||
height: z.number().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
thumbnail: z.optional(
|
|
||||||
z.object({
|
|
||||||
url: z.string().optional(),
|
|
||||||
width: z.number().optional(),
|
|
||||||
height: z.number().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
video: z.optional(
|
|
||||||
z.object({
|
|
||||||
url: z.string().optional(),
|
|
||||||
width: z.number().optional(),
|
|
||||||
height: z.number().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
provider: z.optional(
|
|
||||||
z.object({
|
|
||||||
name: z.string(),
|
|
||||||
url: z.string().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
fields: z.optional(
|
|
||||||
z.array(
|
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().optional(),
|
text: z.string(),
|
||||||
value: z.string().optional(),
|
icon_url: z.string().optional(),
|
||||||
inline: z.boolean().optional(),
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
|
|
||||||
author: z
|
image: z.optional(
|
||||||
.optional(
|
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
|
||||||
url: z.string().optional(),
|
url: z.string().optional(),
|
||||||
width: z.number().optional(),
|
width: z.number().optional(),
|
||||||
height: z.number().optional(),
|
height: z.number().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
),
|
||||||
.nullable(),
|
|
||||||
}).meta({
|
thumbnail: z.optional(
|
||||||
id: "embedInput",
|
z.object({
|
||||||
});
|
url: z.string().optional(),
|
||||||
|
width: z.number().optional(),
|
||||||
|
height: z.number().optional(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
|
video: z.optional(
|
||||||
|
z.object({
|
||||||
|
url: z.string().optional(),
|
||||||
|
width: z.number().optional(),
|
||||||
|
height: z.number().optional(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
|
provider: z.optional(
|
||||||
|
z.object({
|
||||||
|
name: z.string(),
|
||||||
|
url: z.string().optional(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
|
fields: z.optional(
|
||||||
|
z.array(
|
||||||
|
z.object({
|
||||||
|
name: z.string().optional(),
|
||||||
|
value: z.string().optional(),
|
||||||
|
inline: z.boolean().optional(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
author: z
|
||||||
|
.optional(
|
||||||
|
z.object({
|
||||||
|
name: z.string(),
|
||||||
|
url: z.string().optional(),
|
||||||
|
width: z.number().optional(),
|
||||||
|
height: z.number().optional(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.nullable(),
|
||||||
|
})
|
||||||
|
.meta({
|
||||||
|
id: "embedInput",
|
||||||
|
});
|
||||||
|
|
||||||
export type EmbedWith<T extends keyof APIEmbed> = APIEmbed & Pick<Required<APIEmbed>, T>;
|
export type EmbedWith<T extends keyof APIEmbed> = APIEmbed & Pick<Required<APIEmbed>, T>;
|
||||||
|
|
||||||
export const zStrictMessageContent = z.strictObject({
|
export const zStrictMessageContent = z
|
||||||
content: z.string().optional(),
|
.strictObject({
|
||||||
tts: z.boolean().optional(),
|
content: z.string().optional(),
|
||||||
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
|
tts: z.boolean().optional(),
|
||||||
embed: zEmbedInput.optional(),
|
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
|
||||||
}).transform((data) => {
|
embed: zEmbedInput.optional(),
|
||||||
if (data.embed) {
|
})
|
||||||
data.embeds = [data.embed];
|
.transform((data) => {
|
||||||
delete data.embed;
|
if (data.embed) {
|
||||||
}
|
data.embeds = [data.embed];
|
||||||
if (data.embeds && !Array.isArray(data.embeds)) {
|
delete data.embed;
|
||||||
data.embeds = [data.embeds];
|
}
|
||||||
}
|
if (data.embeds && !Array.isArray(data.embeds)) {
|
||||||
return data as StrictMessageContent;
|
data.embeds = [data.embeds];
|
||||||
}).meta({
|
}
|
||||||
id: "strictMessageContent",
|
return data as StrictMessageContent;
|
||||||
});
|
})
|
||||||
|
.meta({
|
||||||
|
id: "strictMessageContent",
|
||||||
|
});
|
||||||
|
|
||||||
export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
|
export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
|
||||||
|
|
||||||
|
@ -295,10 +296,7 @@ export type StrictMessageContent = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MessageContent = string | StrictMessageContent;
|
export type MessageContent = string | StrictMessageContent;
|
||||||
export const zMessageContent = z.union([
|
export const zMessageContent = z.union([zBoundedCharacters(0, 4000), zStrictMessageContent]);
|
||||||
zBoundedCharacters(0, 4000),
|
|
||||||
zStrictMessageContent,
|
|
||||||
]);
|
|
||||||
|
|
||||||
export function validateAndParseMessageContent(input: unknown): StrictMessageContent {
|
export function validateAndParseMessageContent(input: unknown): StrictMessageContent {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
extends: ["../.eslintrc.js"],
|
|
||||||
rules: {
|
|
||||||
"@typescript-eslint/no-unused-vars": 0,
|
|
||||||
"no-self-assign": 0,
|
|
||||||
"no-empty": 0,
|
|
||||||
"@typescript-eslint/no-var-requires": 0,
|
|
||||||
},
|
|
||||||
};
|
|
9
dashboard/.eslintrc.json
Normal file
9
dashboard/.eslintrc.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"extends": ["../.eslintrc.js"],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/no-unused-vars": 0,
|
||||||
|
"no-self-assign": 0,
|
||||||
|
"no-empty": 0,
|
||||||
|
"@typescript-eslint/no-var-requires": 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
body {
|
body {
|
||||||
font: normal 18px/1.5 sans-serif;
|
font: normal 18px/1.5 sans-serif;
|
||||||
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
|
font-family:
|
||||||
|
system,
|
||||||
|
-apple-system,
|
||||||
|
".SFNSText-Regular",
|
||||||
|
"San Francisco",
|
||||||
|
"Roboto",
|
||||||
|
"Segoe UI",
|
||||||
|
"Helvetica Neue",
|
||||||
|
"Lucida Grande",
|
||||||
|
sans-serif;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
|
|
||||||
@media (width < theme(--breakpoint-lg)) {
|
@media (width < theme(--breakpoint-lg)) {
|
||||||
.docs-sidebar.closed:not(:focus-within) {
|
.docs-sidebar.closed:not(:focus-within) {
|
||||||
@apply sr-only;
|
@apply sr-only;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
|
|
||||||
& li:not(:first-child)::before {
|
& li:not(:first-child)::before {
|
||||||
display: block;
|
display: block;
|
||||||
content: ' ';
|
content: " ";
|
||||||
width: 4px;
|
width: 4px;
|
||||||
height: 4px;
|
height: 4px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|
2
dashboard/src/vite-env.d.ts
vendored
2
dashboard/src/vite-env.d.ts
vendored
|
@ -1,6 +1,6 @@
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
declare module '*.html' {
|
declare module "*.html" {
|
||||||
const value: string;
|
const value: string;
|
||||||
export default value;
|
export default value;
|
||||||
}
|
}
|
||||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -21,7 +21,7 @@
|
||||||
"@typescript-eslint/parser": "^5.59.5",
|
"@typescript-eslint/parser": "^5.59.5",
|
||||||
"eslint": "^8.40.0",
|
"eslint": "^8.40.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^3.5.3",
|
||||||
"prettier-plugin-organize-imports": "^3.2.2",
|
"prettier-plugin-organize-imports": "^3.2.2",
|
||||||
"ts-toolbelt": "^9.6.0",
|
"ts-toolbelt": "^9.6.0",
|
||||||
"tsc-watch": "^6.0.4",
|
"tsc-watch": "^6.0.4",
|
||||||
|
@ -9370,14 +9370,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "2.8.8",
|
"version": "3.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
|
||||||
|
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin-prettier.js"
|
"prettier": "bin/prettier.cjs"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=14"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"@typescript-eslint/parser": "^5.59.5",
|
"@typescript-eslint/parser": "^5.59.5",
|
||||||
"eslint": "^8.40.0",
|
"eslint": "^8.40.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^3.5.3",
|
||||||
"prettier-plugin-organize-imports": "^3.2.2",
|
"prettier-plugin-organize-imports": "^3.2.2",
|
||||||
"ts-toolbelt": "^9.6.0",
|
"ts-toolbelt": "^9.6.0",
|
||||||
"tsc-watch": "^6.0.4",
|
"tsc-watch": "^6.0.4",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue