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

Commit 1112342

Browse files
committed
fix: narrow channel types to TextChannel
1 parent 7582b6c commit 1112342

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/events/onMessage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const onMessage = async (bot: ExtendedClient, message: Message) => {
5656
return;
5757
}
5858

59-
const sent = await message.channel.send({
59+
const channel = message.channel as TextChannel;
60+
const sent = await channel.send({
6061
embeds: triggeredWarnings.slice(0, 1),
6162
});
6263
await Warnings.create({

src/events/onUpdate.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type APIEmbed,
44
type Message,
55
type PartialMessage,
6+
type TextChannel,
67
} from 'discord.js';
78
import { checkContent } from '../alexjs/checkContent.js';
89
import { checkBannedWords } from '../alexjs/checkBannedWords.js';
@@ -33,7 +34,9 @@ export const onUpdate = async (
3334

3435
const linkMessage = await checkLinks(bot, newMessage);
3536
if (linkMessage) {
36-
const adminChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!);
37+
const adminChannel = bot.channels.cache.get(
38+
process.env.ADMIN_CHANNEL!,
39+
) as TextChannel;
3740
if (adminChannel && adminChannel.isTextBased()) {
3841
await adminChannel.send({
3942
embeds: [linkMessage],
@@ -47,7 +50,9 @@ export const onUpdate = async (
4750
const newContent = newMessage.content;
4851

4952
if (oldContent !== newContent) {
50-
const logChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!);
53+
const logChannel = bot.channels.cache.get(
54+
process.env.ADMIN_CHANNEL!,
55+
) as TextChannel;
5156
if (logChannel && logChannel.isTextBased()) {
5257
const logEmbed = new EmbedBuilder()
5358
.setTitle(`Message Updated by "${newMessage.author?.username}"`)
@@ -103,7 +108,8 @@ export const onUpdate = async (
103108

104109
// when edit results in new warning, but no existing warning
105110
if (!savedWarning && triggeredWarnings.length) {
106-
const sent = await newMessage.channel.send({
111+
const channel = newMessage.channel as TextChannel;
112+
const sent = await channel.send({
107113
embeds: triggeredWarnings.slice(0, 1),
108114
});
109115
await Warnings.create({

0 commit comments

Comments
 (0)