From c39915acf0782d48d323c64cd85bffebb69de8a0 Mon Sep 17 00:00:00 2001 From: zhiyan114 Date: Sat, 12 Oct 2024 18:10:52 -0400 Subject: [PATCH] Updated to reflect new discordJS channel API --- src/events/ready.ts | 4 ++-- src/utils/close.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index 761a660b..5299b26c 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,7 +1,7 @@ import readline from "readline"; import axios from "axios"; import {client as WebSocketClient, connection} from "websocket"; -import {ActionRowBuilder, ButtonBuilder, ButtonStyle, ColorResolvable, EmbedBuilder, Message} from "discord.js"; +import {ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, ColorResolvable, EmbedBuilder, Message} from "discord.js"; import os from "os"; import {BaseEvent, ExtendedClient, SponsorType} from "../structure"; @@ -87,7 +87,7 @@ export default class ReadyEvent extends BaseEvent { }); } else { const channel = this.client.channels.cache.get(this.client.config.openTicketChannelId); - if(!channel || !channel.isTextBased()) return console.error("Invalid openTicketChannelId"); + if(!channel || channel.type !== ChannelType.GuildText) return console.error("Invalid openTicketChannelId"); channel.send({ embeds: [embed], components: [row] diff --git a/src/utils/close.ts b/src/utils/close.ts index 1a15aa2d..cc616813 100644 --- a/src/utils/close.ts +++ b/src/utils/close.ts @@ -147,6 +147,10 @@ export async function close( components: [rowAction] }) .catch((e) => console.log(e)); + + // Workaround for type handling, rewrite should not follow this. + if(interaction.channel && interaction.channel.type !== ChannelType.GuildText) + throw Error("Close util used in a non-text channel"); interaction.channel ?.send({