3
0
Fork 0
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:
almeidx 2025-06-01 16:05:34 +01:00
parent 3ef89246ba
commit 3722393ec0
No known key found for this signature in database
40 changed files with 13085 additions and 13040 deletions

View file

@ -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);
} }
} }

View file

@ -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";

View file

@ -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, configSchema: plugin.configSchema,
defaultOverrides: plugin.defaultOverrides ?? [], defaultOverrides: plugin.defaultOverrides ?? [],
levels: {}, levels: {},
customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions, customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions,
}, });
);
try { try {
await configManager.init(); await configManager.init();

View file

@ -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; sessionTokenPromise = null;
}, timeUntilExpiry - 1 * MINUTES); // Subtract a minute to ensure we refresh before expiry },
timeUntilExpiry - 1 * MINUTES,
); // Subtract a minute to ensure we refresh before expiry
return parseResult.data.token; return parseResult.data.token;
})(); })();

View file

@ -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); this.clearIgnoredLog(type, ignoreId);
}, timeout || 1000 * 15); },
timeout || 1000 * 15,
);
} }
isLogIgnored(type: keyof typeof LogType, ignoreId: any) { isLogIgnored(type: keyof typeof LogType, ignoreId: any) {

View file

@ -34,7 +34,8 @@ const basePluginOverrideCriteriaSchema = z.strictObject({
extra: z.any().optional(), extra: z.any().optional(),
}); });
const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema.extend({ const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema
.extend({
get zzz_dummy_property_do_not_use() { get zzz_dummy_property_do_not_use() {
return pluginOverrideCriteriaSchema.optional(); return pluginOverrideCriteriaSchema.optional();
}, },
@ -47,7 +48,8 @@ const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema.extend({
get not() { get not() {
return pluginOverrideCriteriaSchema.optional(); return pluginOverrideCriteriaSchema.optional();
}, },
}).meta({ })
.meta({
id: "overrideCriteria", id: "overrideCriteria",
}); });

View file

@ -199,14 +199,17 @@ setInterval(() => {
avgCount++; avgCount++;
lastCheck = now; lastCheck = now;
}, 500); }, 500);
setInterval(() => { setInterval(
() => {
const avgBlocking = avgTotal / (avgCount || 1); const avgBlocking = avgTotal / (avgCount || 1);
// FIXME: Debug // FIXME: Debug
// tslint:disable-next-line:no-console // tslint:disable-next-line:no-console
console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`); console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`);
avgTotal = 0; avgTotal = 0;
avgCount = 0; avgCount = 0;
}, 5 * 60 * 1000); },
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");

View file

@ -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) => {
map[permName] = z.boolean().nullable(); map[permName] = z.boolean().nullable();
return map; return map;
}, {} as Record<typeof allPermissionNames[number], z.ZodNullable<z.ZodBoolean>>); },
{} 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({

View file

@ -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),

View file

@ -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)!;

View file

@ -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)!;

View file

@ -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 {

View file

@ -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";

View file

@ -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) => {
map[key] = zColor; map[key] = zColor;
return map; return map;
}, {} as Record<typeof caseKeys[number], typeof zColor>); },
{} as Record<(typeof caseKeys)[number], typeof zColor>,
);
const caseIconsTypeMap = caseKeys.reduce((map, key) => { const caseIconsTypeMap = caseKeys.reduce(
(map, key) => {
map[key] = zBoundedCharacters(0, 100); map[key] = zBoundedCharacters(0, 100);
return map; return map;
}, {} as Record<typeof caseKeys[number], z.ZodString>); },
{} 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),

View file

@ -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) {

View file

@ -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;

View file

@ -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) => {
map[type] = zMessageContent.default(DefaultLogMessages[type] || ""); map[type] = zMessageContent.default(DefaultLogMessages[type] || "");
return map; return map;
}, {} as Record<keyof typeof LogType, typeof zMessageContentWithDefault>); },
{} 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({

View file

@ -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,
); );

View file

@ -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;

View file

@ -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,
); );
}, },

View file

@ -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;

View file

@ -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,
); );

View file

@ -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;

View file

@ -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,
); );
}, },

View file

@ -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;

View file

@ -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: {};
} }

View file

@ -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"),

View file

@ -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) {

View file

@ -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;
} }

View file

@ -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,7 +193,8 @@ export function zRegex<T extends ZodString>(zStr: T) {
}); });
} }
export const zEmbedInput = z.strictObject({ export const zEmbedInput = z
.strictObject({
title: z.string().optional(), title: z.string().optional(),
description: z.string().optional(), description: z.string().optional(),
url: z.string().optional(), url: z.string().optional(),
@ -262,18 +259,21 @@ export const zEmbedInput = z.strictObject({
}), }),
) )
.nullable(), .nullable(),
}).meta({ })
.meta({
id: "embedInput", 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
.strictObject({
content: z.string().optional(), content: z.string().optional(),
tts: z.boolean().optional(), tts: z.boolean().optional(),
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(), embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
embed: zEmbedInput.optional(), embed: zEmbedInput.optional(),
}).transform((data) => { })
.transform((data) => {
if (data.embed) { if (data.embed) {
data.embeds = [data.embed]; data.embeds = [data.embed];
delete data.embed; delete data.embed;
@ -282,7 +282,8 @@ export const zStrictMessageContent = z.strictObject({
data.embeds = [data.embeds]; data.embeds = [data.embeds];
} }
return data as StrictMessageContent; return data as StrictMessageContent;
}).meta({ })
.meta({
id: "strictMessageContent", id: "strictMessageContent",
}); });
@ -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) {

View file

@ -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
View 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
}
}

View file

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />

View file

@ -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;
} }

View file

@ -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%;

View file

@ -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
View file

@ -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"

View file

@ -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",