Updated types for channels
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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<void> {
|
||||
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" })) {
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user