Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
fix: narrow channel types to TextChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-mba committed Sep 23, 2024
1 parent 7582b6c commit 1112342
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/events/onMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
12 changes: 9 additions & 3 deletions src/events/onUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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],
Expand All @@ -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}"`)
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 1112342

Please sign in to comment.