import { ChannelType, MessageFlags, PermissionFlagsBits, SlashCommandSubcommandBuilder } from "discord.js"; import { Command, requirePermission } from "@voidy/framework"; import { ChatbotChannel } from "../../schemas/ChatbotChannel"; export default new Command({ id: "chatbot.channel.remove", use: [requirePermission(PermissionFlagsBits.ManageGuild)], data: new SlashCommandSubcommandBuilder() .setName("remove") .setDescription("Remove chatbot from a channel entirely.") .addChannelOption((option) => option .setName("channel") .setDescription("Channel to remove chatbot from.") .addChannelTypes(ChannelType.GuildText) .setRequired(true), ), execute: async ({ interaction }) => { const channel = interaction.options.getChannel("channel", true); const doc = await ChatbotChannel.findOneAndDelete({ channelId: channel.id }); if (!doc) { await interaction.reply({ content: `Chatbot is not set up in <#${channel.id}>.`, flags: [MessageFlags.Ephemeral], }); return; } await interaction.reply({ content: `Chatbot removed from <#${channel.id}>.`, flags: [MessageFlags.Ephemeral], }); }, });