mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-27 11:15:02 +00:00
half the number of errors
This commit is contained in:
parent
7c5e6eb91f
commit
1dca8c4447
261 changed files with 760 additions and 1023 deletions
|
@ -1,4 +1,4 @@
|
|||
import { EmbedData } from "discord.js";
|
||||
import { APIEmbed, EmbedData } from "discord.js";
|
||||
|
||||
function sumStringLengthsRecursively(obj: any): number {
|
||||
if (obj == null) return 0;
|
||||
|
@ -12,6 +12,6 @@ function sumStringLengthsRecursively(obj: any): number {
|
|||
return 0;
|
||||
}
|
||||
|
||||
export function calculateEmbedSize(embed: EmbedData): number {
|
||||
export function calculateEmbedSize(embed: APIEmbed | EmbedData): number {
|
||||
return sumStringLengthsRecursively(embed);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
Client,
|
||||
GuildTextBasedChannel,
|
||||
Message,
|
||||
MessageCreateOptions,
|
||||
MessageEditOptions,
|
||||
|
@ -8,7 +7,6 @@ import {
|
|||
PartialMessageReaction,
|
||||
PartialUser,
|
||||
TextBasedChannel,
|
||||
TextChannel,
|
||||
User,
|
||||
} from "discord.js";
|
||||
import { Awaitable } from "knub/dist/utils";
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { spawn, Worker, Pool } from "threads";
|
||||
import type { CryptFns } from "./cryptWorker";
|
||||
import { MINUTES } from "../utils";
|
||||
import { env } from "../env";
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ type FilterResult<T> = {
|
|||
* Filter an object's properties based on its values and keys
|
||||
* @return New object with filtered properties
|
||||
*/
|
||||
export function filterObject<T>(
|
||||
export function filterObject<T extends object>(
|
||||
object: T,
|
||||
filterFn: <K extends keyof T>(value: T[K], key: K) => boolean,
|
||||
): FilterResult<T> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Guild, GuildAuditLogsAction, GuildAuditLogsEntry } from "discord.js";
|
||||
import { AuditLogEvent, Guild, GuildAuditLogsEntry } from "discord.js";
|
||||
import { SECONDS, sleep } from "../utils";
|
||||
|
||||
const BATCH_DEBOUNCE_TIME = 2 * SECONDS;
|
||||
|
@ -19,7 +19,7 @@ const batches = new Map<string, Batch>();
|
|||
*/
|
||||
export async function findMatchingAuditLogEntry(
|
||||
guild: Guild,
|
||||
action?: GuildAuditLogsAction,
|
||||
action?: AuditLogEvent,
|
||||
targetId?: string,
|
||||
): Promise<GuildAuditLogsEntry | undefined> {
|
||||
let candidates: GuildAuditLogsEntry[];
|
||||
|
@ -49,7 +49,8 @@ export async function findMatchingAuditLogEntry(
|
|||
const _candidates = Array.from(result?.entries.values() ?? []);
|
||||
|
||||
batches.delete(guild.id);
|
||||
resolve(_candidates);
|
||||
// TODO: Figure out the type
|
||||
resolve(_candidates as any);
|
||||
}),
|
||||
join() {
|
||||
batch._waitUntil = Date.now() + BATCH_DEBOUNCE_TIME;
|
||||
|
|
|
@ -2,5 +2,6 @@ import { GuildPluginData } from "knub";
|
|||
import { getDefaultPrefix } from "knub/dist/commands/commandUtils";
|
||||
|
||||
export function getGuildPrefix(pluginData: GuildPluginData<any>) {
|
||||
// @ts-expect-error: discord.js version mismatch
|
||||
return pluginData.fullConfig.prefix || getDefaultPrefix(pluginData.client);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Channel, ChannelType, DMChannel } from "discord.js";
|
||||
import type { Channel, DMChannel } from "discord.js";
|
||||
|
||||
export function isDmChannel(channel: Channel): channel is DMChannel {
|
||||
return channel.isDMBased();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Channel, GuildBasedChannel, GuildChannel } from "discord.js";
|
||||
import type { Channel, GuildBasedChannel } from "discord.js";
|
||||
|
||||
export function isGuildChannel(channel: Channel): channel is GuildBasedChannel {
|
||||
return channel.type.toString().startsWith("GUILD_");
|
||||
return "guild" in channel && channel.guild !== null;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AnyThreadChannel, Channel, ChannelType } from "discord.js";
|
||||
import type { AnyThreadChannel, Channel } from "discord.js";
|
||||
|
||||
export function isThreadChannel(channel: Channel): channel is AnyThreadChannel {
|
||||
return channel.isThread();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { MessageOptions } from "child_process";
|
||||
import { MessageCreateOptions, MessagePayload } from "discord.js";
|
||||
import { MessageCreateOptions } from "discord.js";
|
||||
import { StrictMessageContent } from "../utils.js";
|
||||
|
||||
function embedHasContent(embed: any) {
|
||||
for (const [key, value] of Object.entries(embed)) {
|
||||
|
@ -19,7 +19,7 @@ function embedHasContent(embed: any) {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function messageHasContent(content: string | MessageCreateOptions): boolean {
|
||||
export function messageHasContent(content: string | MessageCreateOptions | StrictMessageContent): boolean {
|
||||
if (typeof content === "string") {
|
||||
return content.trim() !== "";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { MessageCreateOptions } from "discord.js";
|
||||
import { messageHasContent } from "./messageHasContent";
|
||||
import { StrictMessageContent } from "../utils.js";
|
||||
|
||||
export function messageIsEmpty(content: string | MessageCreateOptions): boolean {
|
||||
export function messageIsEmpty(content: string | MessageCreateOptions | StrictMessageContent): boolean {
|
||||
return !messageHasContent(content);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { PermissionFlags } from "discord.js";
|
||||
import type { PermissionFlagsBits } from "discord.js";
|
||||
import { EMPTY_CHAR } from "../utils";
|
||||
|
||||
export const PERMISSION_NAMES: Record<keyof PermissionFlags, string> = {
|
||||
export const PERMISSION_NAMES = {
|
||||
AddReactions: "Add Reactions",
|
||||
Administrator: "Administrator",
|
||||
AttachFiles: "Attach Files",
|
||||
|
@ -43,4 +43,4 @@ export const PERMISSION_NAMES: Record<keyof PermissionFlags, string> = {
|
|||
ViewGuildInsights: "View Guild Insights",
|
||||
ModerateMembers: "Moderate Members",
|
||||
ManageEvents: "Manage Events",
|
||||
};
|
||||
} as const satisfies Record<keyof typeof PermissionFlagsBits, string>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildTextBasedChannel, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildTextBasedChannel, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { getChannelIdFromMessageId } from "../data/getChannelIdFromMessageId";
|
||||
import { isSnowflake } from "../utils";
|
||||
|
|
|
@ -8,3 +8,7 @@ export declare type WithRequiredProps<T, K extends keyof T> = T & {
|
|||
|
||||
// https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/
|
||||
export type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
|
||||
|
||||
export type DeepMutable<T> = {
|
||||
-readonly [P in keyof T]: DeepMutable<T[P]>;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Not } from "../utils";
|
||||
|
||||
const scalarTypes = ["string", "number", "boolean", "bigint"];
|
||||
|
||||
export class ObjectAliasError extends Error {}
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
import {
|
||||
ActionRow,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonComponent,
|
||||
ButtonStyle,
|
||||
GuildTextBasedChannel,
|
||||
Message,
|
||||
MessageActionRowComponentBuilder,
|
||||
MessageComponentInteraction,
|
||||
MessageCreateOptions,
|
||||
MessagePayloadOption,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
import { noop } from "knub/dist/utils";
|
||||
import moment from "moment";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue