mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-05 18:27:18 +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 {
|
||||
constructor(message: string, public elapsedTimeMs: number) {
|
||||
constructor(
|
||||
message: string,
|
||||
public elapsedTimeMs: number,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import express from "express";
|
||||
import z from "zod/v4";
|
||||
import { $ZodPipeDef } from "zod/v4/core";
|
||||
import { availableGuildPlugins } from "../plugins/availablePlugins.js";
|
||||
import { ZeppelinGuildPluginInfo } from "../types.js";
|
||||
import { indentLines } from "../utils.js";
|
||||
import { notFound } from "./responses.js";
|
||||
import { $ZodPipeDef } from "zod/v4/core";
|
||||
|
||||
function isZodObject(schema: z.ZodType): schema is z.ZodObject<any> {
|
||||
return schema.def.type === "object";
|
||||
|
|
|
@ -28,15 +28,12 @@ export async function validateGuildConfig(config: any): Promise<string | null> {
|
|||
}
|
||||
|
||||
const plugin = pluginNameToPlugin.get(pluginName)!;
|
||||
const configManager = new PluginConfigManager(
|
||||
pluginOptions,
|
||||
{
|
||||
configSchema: plugin.configSchema,
|
||||
defaultOverrides: plugin.defaultOverrides ?? [],
|
||||
levels: {},
|
||||
customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions,
|
||||
},
|
||||
);
|
||||
const configManager = new PluginConfigManager(pluginOptions, {
|
||||
configSchema: plugin.configSchema,
|
||||
defaultOverrides: plugin.defaultOverrides ?? [],
|
||||
levels: {},
|
||||
customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions,
|
||||
});
|
||||
|
||||
try {
|
||||
await configManager.init();
|
||||
|
|
|
@ -59,9 +59,12 @@ async function getSessionToken(): Promise<string> {
|
|||
}
|
||||
|
||||
const timeUntilExpiry = Date.now() - parseResult.data.expires * 1000;
|
||||
setTimeout(() => {
|
||||
sessionTokenPromise = null;
|
||||
}, timeUntilExpiry - 1 * MINUTES); // Subtract a minute to ensure we refresh before expiry
|
||||
setTimeout(
|
||||
() => {
|
||||
sessionTokenPromise = null;
|
||||
},
|
||||
timeUntilExpiry - 1 * MINUTES,
|
||||
); // Subtract a minute to ensure we refresh before expiry
|
||||
|
||||
return parseResult.data.token;
|
||||
})();
|
||||
|
|
|
@ -40,9 +40,12 @@ export class GuildLogs extends events.EventEmitter {
|
|||
this.ignoredLogs.push({ type, ignoreId });
|
||||
|
||||
// Clear after expiry (15sec by default)
|
||||
setTimeout(() => {
|
||||
this.clearIgnoredLog(type, ignoreId);
|
||||
}, timeout || 1000 * 15);
|
||||
setTimeout(
|
||||
() => {
|
||||
this.clearIgnoredLog(type, ignoreId);
|
||||
},
|
||||
timeout || 1000 * 15,
|
||||
);
|
||||
}
|
||||
|
||||
isLogIgnored(type: keyof typeof LogType, ignoreId: any) {
|
||||
|
|
|
@ -34,22 +34,24 @@ const basePluginOverrideCriteriaSchema = z.strictObject({
|
|||
extra: z.any().optional(),
|
||||
});
|
||||
|
||||
const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema.extend({
|
||||
get zzz_dummy_property_do_not_use() {
|
||||
return pluginOverrideCriteriaSchema.optional();
|
||||
},
|
||||
get all() {
|
||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||
},
|
||||
get any() {
|
||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||
},
|
||||
get not() {
|
||||
return pluginOverrideCriteriaSchema.optional();
|
||||
},
|
||||
}).meta({
|
||||
id: "overrideCriteria",
|
||||
});
|
||||
const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema
|
||||
.extend({
|
||||
get zzz_dummy_property_do_not_use() {
|
||||
return pluginOverrideCriteriaSchema.optional();
|
||||
},
|
||||
get all() {
|
||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||
},
|
||||
get any() {
|
||||
return z.array(pluginOverrideCriteriaSchema).optional();
|
||||
},
|
||||
get not() {
|
||||
return pluginOverrideCriteriaSchema.optional();
|
||||
},
|
||||
})
|
||||
.meta({
|
||||
id: "overrideCriteria",
|
||||
});
|
||||
|
||||
const outputPath = process.argv[2];
|
||||
if (!outputPath) {
|
||||
|
|
|
@ -199,14 +199,17 @@ setInterval(() => {
|
|||
avgCount++;
|
||||
lastCheck = now;
|
||||
}, 500);
|
||||
setInterval(() => {
|
||||
const avgBlocking = avgTotal / (avgCount || 1);
|
||||
// FIXME: Debug
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`);
|
||||
avgTotal = 0;
|
||||
avgCount = 0;
|
||||
}, 5 * 60 * 1000);
|
||||
setInterval(
|
||||
() => {
|
||||
const avgBlocking = avgTotal / (avgCount || 1);
|
||||
// FIXME: Debug
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`);
|
||||
avgTotal = 0;
|
||||
avgCount = 0;
|
||||
},
|
||||
5 * 60 * 1000,
|
||||
);
|
||||
|
||||
if (env.DEBUG) {
|
||||
logger.info("NOTE: Bot started in DEBUG mode");
|
||||
|
@ -332,7 +335,7 @@ connect().then(async () => {
|
|||
|
||||
if (loaded.success_emoji || loaded.error_emoji) {
|
||||
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) {
|
||||
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 allPermissionNames = [...permissionNames, ...legacyPermissionNames] as const;
|
||||
|
||||
const permissionTypeMap = allPermissionNames.reduce((map, permName) => {
|
||||
map[permName] = z.boolean().nullable();
|
||||
return map;
|
||||
}, {} as Record<typeof allPermissionNames[number], z.ZodNullable<z.ZodBoolean>>);
|
||||
const permissionTypeMap = allPermissionNames.reduce(
|
||||
(map, permName) => {
|
||||
map[permName] = z.boolean().nullable();
|
||||
return map;
|
||||
},
|
||||
{} as Record<(typeof allPermissionNames)[number], z.ZodNullable<z.ZodBoolean>>,
|
||||
);
|
||||
const zPermissionsMap = z.strictObject(permissionTypeMap);
|
||||
|
||||
export const ChangePermsAction = automodAction({
|
||||
|
|
|
@ -15,8 +15,16 @@ const configSchema = z.strictObject({
|
|||
exclude_guilds: z.array(zSnowflake).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(),
|
||||
include_custom_invite_codes: z.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(),
|
||||
include_custom_invite_codes: z
|
||||
.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),
|
||||
match_messages: z.boolean().default(true),
|
||||
match_embeds: z.boolean().default(false),
|
||||
|
|
|
@ -73,7 +73,10 @@ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
|||
|
||||
if (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);
|
||||
}
|
||||
const regexes = regexCache.get(trigger.exclude_regex)!;
|
||||
|
@ -88,7 +91,10 @@ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
|||
|
||||
if (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);
|
||||
}
|
||||
const regexes = regexCache.get(trigger.include_regex)!;
|
||||
|
|
|
@ -38,7 +38,10 @@ export const MatchRegexTrigger = automodTrigger<MatchResultType>()({
|
|||
|
||||
if (!regexCache.has(trigger)) {
|
||||
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);
|
||||
}
|
||||
const regexes = regexCache.get(trigger)!;
|
||||
|
|
|
@ -44,9 +44,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
|||
let pattern;
|
||||
|
||||
if (trigger.loose_matching) {
|
||||
pattern = [...word]
|
||||
.map((c) => escapeStringRegexp(c))
|
||||
.join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`);
|
||||
pattern = [...word].map((c) => escapeStringRegexp(c)).join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`);
|
||||
} else {
|
||||
pattern = escapeStringRegexp(word);
|
||||
}
|
||||
|
@ -62,10 +60,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
|||
return pattern;
|
||||
});
|
||||
|
||||
const mergedRegex = new RegExp(
|
||||
patterns.map((p) => `(${p})`).join("|"),
|
||||
trigger.case_sensitive ? "" : "i"
|
||||
);
|
||||
const mergedRegex = new RegExp(patterns.map((p) => `(${p})`).join("|"), trigger.case_sensitive ? "" : "i");
|
||||
|
||||
regexCache.set(trigger, [mergedRegex]);
|
||||
}
|
||||
|
@ -84,7 +79,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
|||
for (const regex of regexes) {
|
||||
const match = regex.exec(str);
|
||||
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];
|
||||
|
||||
return {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { GuildPluginData } from "knub";
|
|||
import { splitMessageIntoChunks } from "knub/helpers";
|
||||
import moment from "moment-timezone";
|
||||
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 { caseAbbreviations } from "../caseAbbreviations.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 caseColorsTypeMap = caseKeys.reduce((map, key) => {
|
||||
map[key] = zColor;
|
||||
return map;
|
||||
}, {} as Record<typeof caseKeys[number], typeof zColor>);
|
||||
const caseColorsTypeMap = caseKeys.reduce(
|
||||
(map, key) => {
|
||||
map[key] = zColor;
|
||||
return map;
|
||||
},
|
||||
{} as Record<(typeof caseKeys)[number], typeof zColor>,
|
||||
);
|
||||
|
||||
const caseIconsTypeMap = caseKeys.reduce((map, key) => {
|
||||
map[key] = zBoundedCharacters(0, 100);
|
||||
return map;
|
||||
}, {} as Record<typeof caseKeys[number], z.ZodString>);
|
||||
const caseIconsTypeMap = caseKeys.reduce(
|
||||
(map, key) => {
|
||||
map[key] = zBoundedCharacters(0, 100);
|
||||
return map;
|
||||
},
|
||||
{} as Record<(typeof caseKeys)[number], z.ZodString>,
|
||||
);
|
||||
|
||||
export const zCasesConfig = z.strictObject({
|
||||
log_automatic_actions: z.boolean().default(true),
|
||||
|
|
|
@ -49,7 +49,7 @@ export const CommonPlugin = guildPlugin<CommonPluginType>()({
|
|||
storeAttachmentsAsMessage: async (attachments: Attachment[], backupChannel?: TextBasedChannel | null) => {
|
||||
const attachmentChannelId = pluginData.config.get().attachment_storing_channel;
|
||||
const channel = attachmentChannelId
|
||||
? (pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel
|
||||
? ((pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel)
|
||||
: backupChannel;
|
||||
|
||||
if (!channel) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { CommonPluginType } from "../types.js";
|
||||
import { env } from "../../../env.js";
|
||||
import { CommonPluginType } from "../types.js";
|
||||
|
||||
export function getSuccessEmoji(pluginData: GuildPluginData<CommonPluginType>) {
|
||||
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 { GuildSavedMessages } from "../../data/GuildSavedMessages.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 {
|
||||
TemplateSafeCase,
|
||||
|
@ -30,10 +30,13 @@ const MAX_BATCH_TIME = 5000;
|
|||
// A bit of a workaround so we can pass LogType keys to z.enum()
|
||||
const zMessageContentWithDefault = zMessageContent.default("");
|
||||
const logTypes = keys(LogType);
|
||||
const logTypeProps = logTypes.reduce((map, type) => {
|
||||
map[type] = zMessageContent.default(DefaultLogMessages[type] || "");
|
||||
return map;
|
||||
}, {} as Record<keyof typeof LogType, typeof zMessageContentWithDefault>);
|
||||
const logTypeProps = logTypes.reduce(
|
||||
(map, type) => {
|
||||
map[type] = zMessageContent.default(DefaultLogMessages[type] || "");
|
||||
return map;
|
||||
},
|
||||
{} as Record<keyof typeof LogType, typeof zMessageContentWithDefault>,
|
||||
);
|
||||
const zLogFormats = z.strictObject(logTypeProps);
|
||||
|
||||
const zLogChannel = z.strictObject({
|
||||
|
|
|
@ -77,7 +77,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
[...msg.attachments.values()],
|
||||
mod,
|
||||
ppId,
|
||||
"time" in args ? args.time ?? undefined : undefined,
|
||||
"time" in args ? (args.time ?? undefined) : undefined,
|
||||
args.reason,
|
||||
contactMethods,
|
||||
);
|
||||
|
|
|
@ -68,7 +68,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({
|
|||
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) {
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
|
|
|
@ -72,7 +72,7 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({
|
|||
[...msg.attachments.values()],
|
||||
mod,
|
||||
ppId,
|
||||
"time" in args ? args.time ?? undefined : undefined,
|
||||
"time" in args ? (args.time ?? undefined) : undefined,
|
||||
args.reason,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -52,7 +52,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({
|
|||
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) {
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
|
|
|
@ -103,7 +103,7 @@ export const MuteMsgCmd = modActionsMsgCmd({
|
|||
[...msg.attachments.values()],
|
||||
mod,
|
||||
ppId,
|
||||
"time" in args ? args.time ?? undefined : undefined,
|
||||
"time" in args ? (args.time ?? undefined) : undefined,
|
||||
args.reason,
|
||||
contactMethods,
|
||||
);
|
||||
|
|
|
@ -95,7 +95,7 @@ export const MuteSlashCmd = modActionsSlashCmd({
|
|||
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) {
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
|
|
|
@ -105,7 +105,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({
|
|||
[...msg.attachments.values()],
|
||||
mod,
|
||||
ppId,
|
||||
"time" in args ? args.time ?? undefined : undefined,
|
||||
"time" in args ? (args.time ?? undefined) : undefined,
|
||||
args.reason,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -99,7 +99,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({
|
|||
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) {
|
||||
pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`);
|
||||
return;
|
||||
|
|
|
@ -186,8 +186,8 @@ export async function muteUser(
|
|||
const template = existingMute
|
||||
? config.update_mute_message
|
||||
: muteTime
|
||||
? config.timed_mute_message
|
||||
: config.mute_message;
|
||||
? config.timed_mute_message
|
||||
: config.mute_message;
|
||||
|
||||
let muteMessage: string | null = null;
|
||||
try {
|
||||
|
|
|
@ -7,5 +7,6 @@ export const zPhishermanConfig = z.strictObject({
|
|||
|
||||
export interface PhishermanPluginType extends BasePluginType {
|
||||
configSchema: typeof zPhishermanConfig;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
state: {};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
|
||||
import { U } from "ts-toolbelt";
|
||||
import z from "zod/v4";
|
||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
|
||||
import { keys } from "../../utils.js";
|
||||
|
@ -7,12 +6,13 @@ import { zValidTimezone } from "../../utils/zValidTimezone.js";
|
|||
import { CommonPlugin } from "../Common/CommonPlugin.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) => {
|
||||
map[key] = z.string().default(defaultDateFormats[key]);
|
||||
return map;
|
||||
}, {} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>);
|
||||
const dateFormatTypeMap = keys(defaultDateFormats).reduce(
|
||||
(map, key) => {
|
||||
map[key] = z.string().default(defaultDateFormats[key]);
|
||||
return map;
|
||||
},
|
||||
{} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>,
|
||||
);
|
||||
|
||||
export const zTimeAndDateConfig = z.strictObject({
|
||||
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
|
||||
|
|
|
@ -55,7 +55,7 @@ export async function fetchChannelMessagesToClean(
|
|||
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 requests = 0;
|
||||
while (rawMessagesToClean.length < opts.count) {
|
||||
|
|
|
@ -18,7 +18,7 @@ export async function getInviteInfoEmbed(
|
|||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
inviteCode: string,
|
||||
): Promise<APIEmbed | null> {
|
||||
let invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||
const invite = await resolveInvite(pluginData.client, inviteCode, true);
|
||||
if (!invite) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
APIEmbed,
|
||||
ChannelType,
|
||||
ChatInputCommandInteraction,
|
||||
Client,
|
||||
DiscordAPIError,
|
||||
EmbedData,
|
||||
|
@ -20,14 +19,11 @@ import {
|
|||
Message,
|
||||
MessageCreateOptions,
|
||||
MessageMentionOptions,
|
||||
PartialChannelData,
|
||||
PartialGroupDMChannel,
|
||||
PartialMessage,
|
||||
PartialUser,
|
||||
RoleResolvable,
|
||||
SendableChannels,
|
||||
Sticker,
|
||||
TextBasedChannel,
|
||||
User,
|
||||
} from "discord.js";
|
||||
import emojiRegex from "emoji-regex";
|
||||
|
@ -197,94 +193,99 @@ export function zRegex<T extends ZodString>(zStr: T) {
|
|||
});
|
||||
}
|
||||
|
||||
export const zEmbedInput = z.strictObject({
|
||||
title: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
url: z.string().optional(),
|
||||
timestamp: z.string().optional(),
|
||||
color: z.number().optional(),
|
||||
export const zEmbedInput = z
|
||||
.strictObject({
|
||||
title: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
url: z.string().optional(),
|
||||
timestamp: z.string().optional(),
|
||||
color: z.number().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(
|
||||
footer: z.optional(
|
||||
z.object({
|
||||
name: z.string().optional(),
|
||||
value: z.string().optional(),
|
||||
inline: z.boolean().optional(),
|
||||
text: z.string(),
|
||||
icon_url: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
author: z
|
||||
.optional(
|
||||
image: z.optional(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
url: z.string().optional(),
|
||||
width: z.number().optional(),
|
||||
height: z.number().optional(),
|
||||
}),
|
||||
)
|
||||
.nullable(),
|
||||
}).meta({
|
||||
id: "embedInput",
|
||||
});
|
||||
),
|
||||
|
||||
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({
|
||||
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 const zStrictMessageContent = z.strictObject({
|
||||
content: z.string().optional(),
|
||||
tts: z.boolean().optional(),
|
||||
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
|
||||
embed: zEmbedInput.optional(),
|
||||
}).transform((data) => {
|
||||
if (data.embed) {
|
||||
data.embeds = [data.embed];
|
||||
delete data.embed;
|
||||
}
|
||||
if (data.embeds && !Array.isArray(data.embeds)) {
|
||||
data.embeds = [data.embeds];
|
||||
}
|
||||
return data as StrictMessageContent;
|
||||
}).meta({
|
||||
id: "strictMessageContent",
|
||||
});
|
||||
export const zStrictMessageContent = z
|
||||
.strictObject({
|
||||
content: z.string().optional(),
|
||||
tts: z.boolean().optional(),
|
||||
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
|
||||
embed: zEmbedInput.optional(),
|
||||
})
|
||||
.transform((data) => {
|
||||
if (data.embed) {
|
||||
data.embeds = [data.embed];
|
||||
delete data.embed;
|
||||
}
|
||||
if (data.embeds && !Array.isArray(data.embeds)) {
|
||||
data.embeds = [data.embeds];
|
||||
}
|
||||
return data as StrictMessageContent;
|
||||
})
|
||||
.meta({
|
||||
id: "strictMessageContent",
|
||||
});
|
||||
|
||||
export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
|
||||
|
||||
|
@ -295,10 +296,7 @@ export type StrictMessageContent = {
|
|||
};
|
||||
|
||||
export type MessageContent = string | StrictMessageContent;
|
||||
export const zMessageContent = z.union([
|
||||
zBoundedCharacters(0, 4000),
|
||||
zStrictMessageContent,
|
||||
]);
|
||||
export const zMessageContent = z.union([zBoundedCharacters(0, 4000), zStrictMessageContent]);
|
||||
|
||||
export function validateAndParseMessageContent(input: unknown): StrictMessageContent {
|
||||
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">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
body {
|
||||
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)) {
|
||||
.docs-sidebar.closed:not(:focus-within) {
|
||||
@apply sr-only;
|
||||
@apply sr-only;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
|
||||
& li:not(:first-child)::before {
|
||||
display: block;
|
||||
content: ' ';
|
||||
content: " ";
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
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" />
|
||||
|
||||
declare module '*.html' {
|
||||
declare module "*.html" {
|
||||
const value: string;
|
||||
export default value;
|
||||
}
|
||||
|
|
25698
package-lock.json
generated
25698
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@
|
|||
"@typescript-eslint/parser": "^5.59.5",
|
||||
"eslint": "^8.40.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-organize-imports": "^3.2.2",
|
||||
"ts-toolbelt": "^9.6.0",
|
||||
"tsc-watch": "^6.0.4",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue