From 1112342c6cc693d0f3e820af5155de654cf590e9 Mon Sep 17 00:00:00 2001 From: Dan <35927536+dan-mba@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:10:10 -0400 Subject: [PATCH] fix: narrow channel types to TextChannel --- src/events/onMessage.ts | 3 ++- src/events/onUpdate.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/events/onMessage.ts b/src/events/onMessage.ts index ba607730..a87fc3e1 100644 --- a/src/events/onMessage.ts +++ b/src/events/onMessage.ts @@ -56,7 +56,8 @@ export const onMessage = async (bot: ExtendedClient, message: Message) => { return; } - const sent = await message.channel.send({ + const channel = message.channel as TextChannel; + const sent = await channel.send({ embeds: triggeredWarnings.slice(0, 1), }); await Warnings.create({ diff --git a/src/events/onUpdate.ts b/src/events/onUpdate.ts index b2bc6677..8f45a79d 100644 --- a/src/events/onUpdate.ts +++ b/src/events/onUpdate.ts @@ -3,6 +3,7 @@ import { type APIEmbed, type Message, type PartialMessage, + type TextChannel, } from 'discord.js'; import { checkContent } from '../alexjs/checkContent.js'; import { checkBannedWords } from '../alexjs/checkBannedWords.js'; @@ -33,7 +34,9 @@ export const onUpdate = async ( const linkMessage = await checkLinks(bot, newMessage); if (linkMessage) { - const adminChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!); + const adminChannel = bot.channels.cache.get( + process.env.ADMIN_CHANNEL!, + ) as TextChannel; if (adminChannel && adminChannel.isTextBased()) { await adminChannel.send({ embeds: [linkMessage], @@ -47,7 +50,9 @@ export const onUpdate = async ( const newContent = newMessage.content; if (oldContent !== newContent) { - const logChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!); + const logChannel = bot.channels.cache.get( + process.env.ADMIN_CHANNEL!, + ) as TextChannel; if (logChannel && logChannel.isTextBased()) { const logEmbed = new EmbedBuilder() .setTitle(`Message Updated by "${newMessage.author?.username}"`) @@ -103,7 +108,8 @@ export const onUpdate = async ( // when edit results in new warning, but no existing warning if (!savedWarning && triggeredWarnings.length) { - const sent = await newMessage.channel.send({ + const channel = newMessage.channel as TextChannel; + const sent = await channel.send({ embeds: triggeredWarnings.slice(0, 1), }); await Warnings.create({