3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +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 { configUtils, CooldownManager } from "knub";
import { ConfigParserFn } from "knub/dist/config/configTypes";
import { GuildAntiraidLevels } from "../../data/GuildAntiraidLevels"; import { GuildAntiraidLevels } from "../../data/GuildAntiraidLevels";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";

View file

@ -121,7 +121,7 @@ export const ReplyAction = automodAction({
if (typeof actionConfig === "object" && actionConfig.auto_delete) { if (typeof actionConfig === "object" && actionConfig.auto_delete) {
const delay = convertDelayStringToMS(String(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({ .create({
name: threadName, name: threadName,
autoArchiveDuration: autoArchive, autoArchiveDuration: autoArchive,
// @ts-expect-error FIXME
type: actionConfig.private ? ChannelType.PrivateThread : ChannelType.PublicThread, type: actionConfig.private ? ChannelType.PrivateThread : ChannelType.PublicThread,
startMessage: startMessage:
!actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads) !actionConfig.private && guild.features.includes(GuildFeature.PrivateThreads)

View file

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

View file

@ -3,7 +3,7 @@ import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { log } from "../util/log"; import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter"; import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { GuildTextBasedChannel, User } from "discord.js"; import { GuildBasedChannel, User } from "discord.js";
import { import {
channelToTemplateSafeChannel, channelToTemplateSafeChannel,
savedMessageToTemplateSafeSavedMessage, savedMessageToTemplateSafeSavedMessage,
@ -16,7 +16,7 @@ import { resolveChannelIds } from "../../../utils/resolveChannelIds";
interface LogMessageDeleteAutoData { interface LogMessageDeleteAutoData {
message: SavedMessage; message: SavedMessage;
user: User | UnknownUser; user: User | UnknownUser;
channel: GuildTextBasedChannel; channel: GuildBasedChannel;
messageDate: string; 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 { GuildPluginData } from "knub";
import { allowTimeout } from "../../../RegExpRunner"; import { allowTimeout } from "../../../RegExpRunner";
import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types"; 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)!; const buffer = pluginData.state.buffers.get(channelId)!;
buffer.push({ buffer.push({
content: typeof message === "string" ? message : message.content || "", 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 { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { logger } from "../../../logger"; 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 { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { isValidEmbed, trimLines } from "../../../utils"; 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 (args.title) embed.title = args.title;
if (color) embed.color = color; if (color) embed.color = color;

View file

@ -57,7 +57,6 @@ export async function postScheduledPost(pluginData: GuildPluginData<PostPluginTy
const postedMessage = await postMessage( const postedMessage = await postMessage(
pluginData, pluginData,
channel, channel,
// @ts-expect-error
post.content, post.content,
post.attachments, post.attachments,
post.enable_mentions, 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 { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
@ -8,9 +8,12 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
export async function applyBotSlowmodeToUserId( export async function applyBotSlowmodeToUserId(
pluginData: GuildPluginData<SlowmodePluginType>, pluginData: GuildPluginData<SlowmodePluginType>,
channel: GuildChannel & TextChannel, channel: GuildTextBasedChannel,
userId: string, 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. // Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
const existingOverride = channel.permissionOverwrites?.resolve(userId as Snowflake); const existingOverride = channel.permissionOverwrites?.resolve(userId as Snowflake);
try { try {

View file

@ -1,4 +1,4 @@
import { Snowflake } from "discord.js"; import { ChannelType, GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { hasPermission } from "../../../pluginUtils"; import { hasPermission } from "../../../pluginUtils";
@ -15,8 +15,8 @@ import { SlowmodeChannel } from "../../../data/entities/SlowmodeChannel";
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) { export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
if (msg.is_bot) return; if (msg.is_bot) return;
const channel = pluginData.guild.channels.cache.get(msg.channel_id as Snowflake); const channel = pluginData.guild.channels.cache.get(msg.channel_id as Snowflake) as GuildTextBasedChannel;
if (!channel?.isTextBased()) return; 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) // 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)); 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 { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
@ -141,7 +141,9 @@ export async function logAndDetectMessageSpam(
clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id); clearRecentUserActions(pluginData, type, savedMessage.user_id, savedMessage.channel_id);
// Generate a log from the detected messages // 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); const archiveUrl = await saveSpamArchives(pluginData, uniqueMessages);
// Create a case // Create a case

View file

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

View file

@ -1,6 +1,6 @@
import { Snowflake, SnowflakeUtil } from "discord.js"; import { Snowflake, SnowflakeUtil } from "discord.js";
export function idToTimestamp(id: string) { export function idToTimestamp(id: string): string | null {
if (typeof id === "number") return 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 { import {
Emoji, Emoji,
Guild, Guild,
GuildChannel, GuildBasedChannel,
GuildMember, GuildMember,
Message, Message,
PartialGuildMember, PartialGuildMember,
@ -10,7 +10,6 @@ import {
StageInstance, StageInstance,
Sticker, Sticker,
StickerFormatType, StickerFormatType,
ThreadChannel,
User, User,
} from "discord.js"; } from "discord.js";
import { UnknownUser } from "src/utils"; 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({ return new TemplateSafeChannel({
id: channel.id, id: channel.id,
name: channel.name, name: channel.name,
@ -449,7 +448,7 @@ export function messageToTemplateSafeMessage(message: Message): TemplateSafeMess
id: message.id, id: message.id,
content: message.content, content: message.content,
author: userToTemplateSafeUser(message.author), author: userToTemplateSafeUser(message.author),
channel: channelToTemplateSafeChannel(message.channel as GuildChannel | ThreadChannel), channel: channelToTemplateSafeChannel(message.channel as GuildBasedChannel),
}); });
} }