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.enable", use: [requirePermission(PermissionFlagsBits.ManageGuild)], data: new SlashCommandSubcommandBuilder() .setName("enable") .setDescription("Enable chatbot in a channel.") .addChannelOption((option) => option .setName("channel") .setDescription("Channel to enable.") .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: true } }, ); if (!doc) { await interaction.reply({ content: `Chatbot is not set up in <#${channel.id}>. Use \`/chatbot setup\` first.`, flags: [MessageFlags.Ephemeral], }); return; } await interaction.reply({ content: `Chatbot enabled in <#${channel.id}>.`, flags: [MessageFlags.Ephemeral], }); }, });