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.disable", use: [requirePermission(PermissionFlagsBits.ManageGuild)], data: new SlashCommandSubcommandBuilder() .setName("disable") .setDescription("Disable chatbot in a channel.") .addChannelOption((option) => option .setName("channel") .setDescription("Channel to disable.") .addChannelTypes(ChannelType.GuildText) .setRequired(true), ), execute: async ({ interaction }) => { const channel = interaction.options.getChannel("channel", true); const doc = await ChatbotChannel.findOneAndUpdate( { channelId: channel.id }, { $set: { enabled: false } }, ); if (!doc) { await interaction.reply({ content: `Chatbot is not set up in <#${channel.id}>.`, flags: [MessageFlags.Ephemeral], }); return; } await interaction.reply({ content: `Chatbot disabled in <#${channel.id}>.`, flags: [MessageFlags.Ephemeral], }); }, });