3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

more minor typings fixes - 23 err left

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
metal 2023-03-12 16:51:26 +00:00 committed by GitHub
parent 69f2f3d516
commit 9956af7c69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 28 additions and 25 deletions

View file

@ -1,5 +1,4 @@
import { configUtils, CooldownManager } from "knub";
import { ConfigParserFn } from "knub/dist/config/configTypes";
import { GuildAntiraidLevels } from "../../data/GuildAntiraidLevels";
import { GuildArchives } from "../../data/GuildArchives";
import { GuildLogs } from "../../data/GuildLogs";

View file

@ -121,7 +121,7 @@ export const ReplyAction = automodAction({
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
const delay = convertDelayStringToMS(String(actionConfig.auto_delete))!;
setTimeout(() => !replyMsg.deleted && replyMsg.delete().catch(noop), delay);
setTimeout(() => replyMsg.deletable && replyMsg.delete().catch(noop), delay);
}
}
}

View file

@ -66,6 +66,7 @@ export const StartThreadAction = automodAction({
.create({
name: threadName,
autoArchiveDuration: autoArchive,
// @ts-expect-error FIXME
type: actionConfig.private ? ChannelType.PrivateThread : ChannelType.PublicThread,
startMessage:
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)

View file

@ -43,7 +43,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin<CustomEventsPluginType>()(
safeArgs[argKey] = userToTemplateSafeUser(argValue);
} else if (argValue instanceof GuildMember) {
safeArgs[argKey] = memberToTemplateSafeMember(argValue);
} else if (argValue instanceof GuildChannel || argValue instanceof ThreadChannel) {
} else if (argValue instanceof GuildChannel && argValue.isTextBased()) {
safeArgs[argKey] = channelToTemplateSafeChannel(argValue);
} else if (isScalar(argValue)) {
safeArgs[argKey] = argValue;

View file

@ -3,7 +3,7 @@ import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType";
import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { GuildTextBasedChannel, User } from "discord.js";
import { GuildBasedChannel, User } from "discord.js";
import {
channelToTemplateSafeChannel,
savedMessageToTemplateSafeSavedMessage,
@ -16,7 +16,7 @@ import { resolveChannelIds } from "../../../utils/resolveChannelIds";
interface LogMessageDeleteAutoData {
message: SavedMessage;
user: User | UnknownUser;
channel: GuildTextBasedChannel;
channel: GuildBasedChannel;
messageDate: string;
}

View file

@ -1,4 +1,4 @@
import { EmbedData, MessageMentionTypes, Snowflake } from "discord.js";
import { APIEmbed, MessageMentionTypes, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { allowTimeout } from "../../../RegExpRunner";
import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types";
@ -141,7 +141,7 @@ export async function log<TLogType extends keyof ILogTypeData>(
const buffer = pluginData.state.buffers.get(channelId)!;
buffer.push({
content: typeof message === "string" ? message : message.content || "",
embeds: typeof message === "string" ? [] : ((message.embeds || []) as EmbedData[]),
embeds: typeof message === "string" ? [] : ((message.embeds || []) as APIEmbed[]),
});
}
}

View file

@ -1,4 +1,4 @@
import { User } from "discord.js";
import { AuditLogEvent, User } from "discord.js";
import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case";
import { logger } from "../../../logger";

View file

@ -1,4 +1,4 @@
import { EmbedData } from "discord.js";
import { APIEmbed } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { isValidEmbed, trimLines } from "../../../utils";
@ -46,7 +46,7 @@ export const PostEmbedCmd = postCmd({
}
}
let embed: EmbedData = {};
let embed: APIEmbed = {};
if (args.title) embed.title = args.title;
if (color) embed.color = color;

View file

@ -57,7 +57,6 @@ export async function postScheduledPost(pluginData: GuildPluginData<PostPluginTy
const postedMessage = await postMessage(
pluginData,
channel,
// @ts-expect-error
post.content,
post.attachments,
post.enable_mentions,

View file

@ -1,4 +1,4 @@
import { GuildChannel, Snowflake, TextChannel } from "discord.js";
import { GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger";
@ -8,9 +8,12 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
export async function applyBotSlowmodeToUserId(
pluginData: GuildPluginData<SlowmodePluginType>,
channel: GuildChannel & TextChannel,
channel: GuildTextBasedChannel,
userId: string,
) {
// FIXME: Is there a better way to do this?
if (channel.isThread()) return;
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
const existingOverride = channel.permissionOverwrites?.resolve(userId as Snowflake);
try {

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord.js";
import { ChannelType, GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { hasPermission } from "../../../pluginUtils";
@ -15,8 +15,8 @@ import { SlowmodeChannel } from "../../../data/entities/SlowmodeChannel";
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
if (msg.is_bot) return;
const channel = pluginData.guild.channels.cache.get(msg.channel_id as Snowflake);
if (!channel?.isTextBased()) return;
const channel = pluginData.guild.channels.cache.get(msg.channel_id as Snowflake) as GuildTextBasedChannel;
if (!channel?.isTextBased() || channel.type === ChannelType.GuildStageVoice) return;
// Don't apply slowmode if the lock was interrupted earlier (e.g. the message was caught by word filters)
const thisMsgLock = await pluginData.locks.acquire(messageLock(msg));

View file

@ -1,4 +1,4 @@
import { Snowflake, TextChannel } from "discord.js";
import { GuildTextBasedChannel, Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes";
@ -141,7 +141,9 @@ export async function logAndDetectMessageSpam(
clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id);
// Generate a log from the detected messages
const channel = pluginData.guild.channels.cache.get(savedMessage.channel_id as Snowflake);
const channel = pluginData.guild.channels.cache.get(
savedMessage.channel_id as Snowflake,
) as GuildTextBasedChannel;
const archiveUrl = await saveSpamArchives(pluginData, uniqueMessages);
// Create a case

View file

@ -401,7 +401,7 @@ export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
export type StrictMessageContent = {
content?: string;
tts?: boolean;
embeds?: EmbedData[];
embeds?: APIEmbed[];
};
export const tStrictMessageContent = t.type({

View file

@ -1,6 +1,6 @@
import { Snowflake, SnowflakeUtil } from "discord.js";
export function idToTimestamp(id: string) {
export function idToTimestamp(id: string): string | null {
if (typeof id === "number") return null;
return SnowflakeUtil.deconstruct(id as Snowflake).timestamp;
return SnowflakeUtil.deconstruct(id as Snowflake).timestamp.toString();
}

View file

@ -1,7 +1,7 @@
import {
Emoji,
Guild,
GuildChannel,
GuildBasedChannel,
GuildMember,
Message,
PartialGuildMember,
@ -10,7 +10,6 @@ import {
StageInstance,
Sticker,
StickerFormatType,
ThreadChannel,
User,
} from "discord.js";
import { UnknownUser } from "src/utils";
@ -269,7 +268,7 @@ export function memberToTemplateSafeMember(member: GuildMember | PartialGuildMem
});
}
export function channelToTemplateSafeChannel(channel: GuildChannel | ThreadChannel): TemplateSafeChannel {
export function channelToTemplateSafeChannel(channel: GuildBasedChannel): TemplateSafeChannel {
return new TemplateSafeChannel({
id: channel.id,
name: channel.name,
@ -449,7 +448,7 @@ export function messageToTemplateSafeMessage(message: Message): TemplateSafeMess
id: message.id,
content: message.content,
author: userToTemplateSafeUser(message.author),
channel: channelToTemplateSafeChannel(message.channel as GuildChannel | ThreadChannel),
channel: channelToTemplateSafeChannel(message.channel as GuildBasedChannel),
});
}