diff --git a/src/commands/clear.ts b/src/commands/clear.ts index 2e6a71d..db92a92 100644 --- a/src/commands/clear.ts +++ b/src/commands/clear.ts @@ -1,8 +1,7 @@ import { SlashCommandBuilder, PermissionFlagsBits, - ChannelType, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color } from "../../config/options.json" import { Command } from "../interfaces" @@ -30,7 +29,7 @@ export = { await interaction.deferReply({ ephemeral: true }) const amount = interaction.options.getInteger("amount")! - const channel2 = interaction.channel! + const channel = interaction.channel as TextChannel const embedColor = Number(color.replace("#", "0x")) if (!amount || amount < 1 || amount > 100) { @@ -45,20 +44,6 @@ export = { }) } - if (channel2.type !== ChannelType.GuildText) { - await interaction.editReply({ - embeds: [ - { - description: - "You can only clear messages in a text channel", - color: embedColor, - }, - ], - }) - } - - const channel = channel2 as GuildTextBasedChannel - channel.messages.fetch({ limit: amount }).then(async messages => { const messagesToDelete = messages .map(m => m) diff --git a/src/commands/counting/setup.ts b/src/commands/counting/setup.ts index 26050c4..6ebce53 100644 --- a/src/commands/counting/setup.ts +++ b/src/commands/counting/setup.ts @@ -1,4 +1,4 @@ -import { ChatInputCommandInteraction, GuildTextBasedChannel, channelMention } from "discord.js" +import { ChatInputCommandInteraction, TextChannel, channelMention } from "discord.js" import settingsSchema from "../../schemas/settingsSchema" import { color, devMessage } from "../../../config/options.json" import mongoose from "mongoose" @@ -6,7 +6,7 @@ import mongoose from "mongoose" export default async function setup(interaction: ChatInputCommandInteraction): Promise { await interaction.deferReply() - const channel = interaction.options.getChannel("channel") as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel const embedColor = Number(color.replace("#", "0x")) if (await settingsSchema.findOne({ name: "counting" })) { diff --git a/src/commands/send.ts b/src/commands/send.ts index 3700262..bf38d18 100644 --- a/src/commands/send.ts +++ b/src/commands/send.ts @@ -2,7 +2,7 @@ import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" @@ -26,7 +26,8 @@ export = { .addChannelOption(option => option .setName("channel") - .setDescription("The channel to send the message to."), + .setDescription("The channel to send the message to.") + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) ) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDMPermission(false), @@ -35,32 +36,9 @@ export = { await interaction.deferReply({ ephemeral: true }) const message = interaction.options.getString("message")! - const channel2 = - interaction.options.getChannel("channel") ?? interaction.channel + const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel const embedColor = Number(color.replace("#", "0x")) - if (channel2?.type !== ChannelType.GuildText) { - await interaction.editReply({ - embeds: [ - { - description: - "You can only send a message to a text channel.", - color: embedColor, - footer: { - text: interaction.guild!.name + " | " + devMessage, - icon_url: - interaction.guild!.iconURL({ - forceStatic: false, - }) || undefined, - }, - }, - ], - }) - return - } - - const channel = channel2 as GuildTextBasedChannel - channel.send({ embeds: [ { diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 66b66b9..36d1d23 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -5,7 +5,7 @@ import { ActionRowBuilder, ButtonStyle, ChannelType, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" @@ -31,6 +31,7 @@ export = { .setDescription( "The channel to send the application to.", ) + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) .setRequired(true), ), ) @@ -44,6 +45,7 @@ export = { .setDescription( "The channel to send the application to.", ) + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) .setRequired(true), ), ) @@ -57,6 +59,7 @@ export = { .setDescription( "The channel to send the verfiy message to.", ) + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) .setRequired(true), ), ) @@ -70,6 +73,7 @@ export = { .setDescription( "The channel to send the waiting list message to.", ) + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) .setRequired(true), ), ) @@ -83,6 +87,7 @@ export = { .setDescription( "The channel to send the application to.", ) + .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement) .setRequired(true), ), ) @@ -94,17 +99,7 @@ export = { const embedColor = Number(color.replace("#", "0x")) if (subcommand === "sendguildapplication") { - const channel2 = interaction.options.getChannel("channel")! - - if (channel2.type !== ChannelType.GuildText) { - await interaction.reply({ - content: "That channel is not a text channel.", - ephemeral: true, - }) - return - } - - const channel = channel2 as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel await channel.send({ embeds: [ @@ -145,17 +140,7 @@ export = { } if (subcommand === "sendstaffapplication") { - const channel2 = interaction.options.getChannel("channel")! - - if (channel2.type !== ChannelType.GuildText) { - await interaction.reply({ - content: "That channel is not a text channel.", - ephemeral: true, - }) - return - } - - const channel = channel2 as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel await channel.send({ embeds: [ @@ -195,17 +180,7 @@ export = { } if (subcommand === "sendinactivityapplication") { - const channel2 = interaction.options.getChannel("channel")! - - if (channel2.type !== ChannelType.GuildText) { - await interaction.reply({ - content: "That channel is not a text channel.", - ephemeral: true, - }) - return - } - - const channel = channel2 as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel await channel.send({ embeds: [ @@ -245,17 +220,7 @@ export = { } if (subcommand === "sendverfiymessage") { - const channel2 = interaction.options.getChannel("channel")! - - if (channel2.type !== ChannelType.GuildText) { - await interaction.reply({ - content: "That channel is not a text channel.", - ephemeral: true, - }) - return - } - - const channel = channel2 as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel await channel.send({ embeds: [ @@ -294,17 +259,7 @@ export = { } if (subcommand === "sendwaitinglistmessage") { - const channel2 = interaction.options.getChannel("channel")! - - if (channel2.type !== ChannelType.GuildText) { - await interaction.reply({ - content: "That channel is not a text channel.", - ephemeral: true, - }) - return - } - - const channel = channel2 as GuildTextBasedChannel + const channel = interaction.options.getChannel("channel") as TextChannel await channel.send({ embeds: [ diff --git a/src/commands/slowmode.ts b/src/commands/slowmode.ts index bccbb88..5eb4dac 100644 --- a/src/commands/slowmode.ts +++ b/src/commands/slowmode.ts @@ -2,7 +2,7 @@ import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color, devMessage } from "../../config/options.json" import { Command } from "../interfaces" @@ -27,7 +27,8 @@ export = { .addChannelOption(option => option .setName("channel") - .setDescription("The channel to set the slowmode of."), + .setDescription("The channel to set the slowmode of.") + .addChannelTypes(ChannelType.GuildText), ) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) .setDMPermission(false), @@ -36,32 +37,9 @@ export = { await interaction.deferReply({ ephemeral: true }) const seconds = interaction.options.getInteger("seconds") ?? 5 - const channel2 = - interaction.options.getChannel("channel") ?? interaction.channel + const channel = (interaction.options.getChannel("channel") || interaction.channel) as TextChannel const embedColor = Number(color.replace("#", "0x")) - if (channel2?.type !== ChannelType.GuildText) { - await interaction.editReply({ - embeds: [ - { - description: - "You can only set the slowmode of a text channel.", - color: embedColor, - footer: { - text: interaction.guild!.name + " | " + devMessage, - icon_url: - interaction.guild!.iconURL({ - forceStatic: false, - }) || undefined, - }, - }, - ], - }) - return - } - - const channel = channel2 as GuildTextBasedChannel - if (seconds > 21600) { await channel.setRateLimitPerUser(21600) await interaction.editReply({ diff --git a/src/components/buttons/guildapplicationaccept.ts b/src/components/buttons/guildapplicationaccept.ts index 99629a9..3cd8baa 100644 --- a/src/components/buttons/guildapplicationaccept.ts +++ b/src/components/buttons/guildapplicationaccept.ts @@ -2,7 +2,7 @@ import { ActionRowBuilder, ButtonStyle, ButtonBuilder, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color, @@ -91,7 +91,7 @@ export = { // update waiting list const channel = guild.channels.cache.get( waitingListChannel, - ) as GuildTextBasedChannel + ) as TextChannel const wlmessage = await channel!.messages.fetch(waitingListMessage) const wlembed = wlmessage.embeds[0] diff --git a/src/components/buttons/guildapply.ts b/src/components/buttons/guildapply.ts index 63dcaab..06cfd18 100644 --- a/src/components/buttons/guildapply.ts +++ b/src/components/buttons/guildapply.ts @@ -4,7 +4,7 @@ import { ActionRowBuilder, EmbedBuilder, GuildMember, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color } from "../../../config/options.json" import { largeM, smallM, ignM } from "../../../config/limitmessages.json" @@ -537,7 +537,7 @@ export = { const channel = guild.channels.cache.get( applicationsChannel, - ) as GuildTextBasedChannel + ) as TextChannel await channel.send({ embeds: [ { diff --git a/src/components/buttons/guildinactivitylog.ts b/src/components/buttons/guildinactivitylog.ts index 5aced77..da79415 100644 --- a/src/components/buttons/guildinactivitylog.ts +++ b/src/components/buttons/guildinactivitylog.ts @@ -4,7 +4,7 @@ import { ButtonStyle, EmbedBuilder, GuildMember, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { gm, @@ -305,7 +305,7 @@ module.exports = { const appChannel = guild.channels.cache.get( inactivityLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel await appChannel.send({ embeds: [ diff --git a/src/components/buttons/staffapply.ts b/src/components/buttons/staffapply.ts index 9128b5a..f031ba0 100644 --- a/src/components/buttons/staffapply.ts +++ b/src/components/buttons/staffapply.ts @@ -4,7 +4,7 @@ import { ActionRowBuilder, EmbedBuilder, GuildMember, - GuildTextBasedChannel, + TextChannel, } from "discord.js" import { color, staffApplicationsChannel } from "../../../config/options.json" import { largeM, ignM } from "../../../config/limitmessages.json" @@ -464,7 +464,7 @@ export = { const channel = guild.channels.cache.get( staffApplicationsChannel, - ) as GuildTextBasedChannel + ) as TextChannel await channel.send({ embeds: [ diff --git a/src/events/cron/weeklyGexp.ts b/src/events/cron/weeklyGexp.ts index 6d7a138..0ade5ee 100644 --- a/src/events/cron/weeklyGexp.ts +++ b/src/events/cron/weeklyGexp.ts @@ -7,13 +7,13 @@ import { import { getGuild, getIGN } from "../../utils/Hypixel" import { Cron, GuildData } from "../../interfaces" import Illegitimate from "../../utils/Illegitimate" -import { GuildTextBasedChannel } from "discord.js" +import { TextChannel } from "discord.js" const client = Illegitimate.client async function guildWeekly() { const channel = client.channels.cache.get( guildLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("Guild log channel not found") diff --git a/src/utils/eventHandlers/autocomplete.ts b/src/utils/eventHandlers/autocomplete.ts index d6b790c..507b216 100644 --- a/src/utils/eventHandlers/autocomplete.ts +++ b/src/utils/eventHandlers/autocomplete.ts @@ -1,7 +1,7 @@ import { ExtendedClient as Client } from "../Client" import { errorLogChannel, color } from "../../../config/options.json" import { Autocomplete } from "../../interfaces" -import { Events, GuildTextBasedChannel } from "discord.js" +import { Events, TextChannel } from "discord.js" import path = require("path") import fs = require("fs") type FileType = "js" | "ts" @@ -54,7 +54,7 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) { if (process.env.NODE_ENV !== "dev") { const channel = client.channels.cache.get( errorLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("No error log channel found.") } diff --git a/src/utils/eventHandlers/button.ts b/src/utils/eventHandlers/button.ts index 549a6cf..2911787 100644 --- a/src/utils/eventHandlers/button.ts +++ b/src/utils/eventHandlers/button.ts @@ -1,7 +1,7 @@ import { ExtendedClient as Client } from "../Client" import { errorLogChannel, color } from "../../../config/options.json" import { Button } from "../../interfaces" -import { Events, GuildTextBasedChannel } from "discord.js" +import { Events, TextChannel } from "discord.js" import path = require("path") import fs = require("fs") type FileType = "js" | "ts" @@ -42,7 +42,7 @@ export default function loadButtonEvents(client: Client, ft: FileType) { if (process.env.NODE_ENV !== "dev") { const channel = client.channels.cache.get( errorLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("No error log channel found.") } diff --git a/src/utils/eventHandlers/command.ts b/src/utils/eventHandlers/command.ts index dc462ac..887275a 100644 --- a/src/utils/eventHandlers/command.ts +++ b/src/utils/eventHandlers/command.ts @@ -1,7 +1,7 @@ import { ExtendedClient as Client } from "../Client" import { errorLogChannel, color } from "../../../config/options.json" import { Command } from "../../interfaces" -import { Events, GuildTextBasedChannel } from "discord.js" +import { Events, TextChannel } from "discord.js" import path = require("path") import fs = require("fs") type FileType = "js" | "ts" @@ -43,7 +43,7 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) { if (process.env.NODE_ENV !== "dev") { const channel = client.channels.cache.get( errorLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("No error log channel found.") } diff --git a/src/utils/eventHandlers/contextmenu.ts b/src/utils/eventHandlers/contextmenu.ts index 86e08e9..b9e2354 100644 --- a/src/utils/eventHandlers/contextmenu.ts +++ b/src/utils/eventHandlers/contextmenu.ts @@ -1,7 +1,7 @@ import { ExtendedClient as Client } from "../Client" import { ContextMenu } from "../../interfaces" import { errorLogChannel, color } from "../../../config/options.json" -import { Events, GuildTextBasedChannel } from "discord.js" +import { Events, TextChannel } from "discord.js" import path = require("path") import fs = require("fs") type FileType = "js" | "ts" @@ -50,7 +50,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) { if (process.env.NODE_ENV !== "dev") { const channel = client.channels.cache.get( errorLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("No error log channel found.") } diff --git a/src/utils/eventHandlers/modal.ts b/src/utils/eventHandlers/modal.ts index feaf5e2..f41d902 100644 --- a/src/utils/eventHandlers/modal.ts +++ b/src/utils/eventHandlers/modal.ts @@ -1,7 +1,7 @@ import { ExtendedClient as Client } from "../Client" import { errorLogChannel, color } from "../../../config/options.json" import { Modal } from "../../interfaces" -import { Events, GuildTextBasedChannel } from "discord.js" +import { Events, TextChannel } from "discord.js" import path = require("path") import fs = require("fs") type FileType = "js" | "ts" @@ -44,7 +44,7 @@ export default function loadModalEvents(client: Client, ft: FileType) { if (process.env.NODE_ENV !== "dev") { const channel = client.channels.cache.get( errorLogChannel, - ) as GuildTextBasedChannel + ) as TextChannel if (!channel) { console.log("No error log channel found.") }