import { Channel, ChatInputCommandInteraction, MessageFlags, SlashCommandSubcommandBuilder } from "discord.js"; import { defineCommand, DiscordCommand } from "../command"; import { insertGuildReadChannel, removeGuildReadChannel } from "../db"; export default defineCommand( new SlashCommandSubcommandBuilder() .setName("읽지마") .setDescription("예주가 해당 채널을 더이상 읽지 않아요") .addChannelOption(option => option .setName("channel") .setDescription("예주가 더이상 읽지 않을 채널이에요") .setRequired(true) ), async (interaction: ChatInputCommandInteraction): Promise => { await interaction.deferReply({ flags: [MessageFlags.Ephemeral] }); const channel = interaction.options.getChannel("channel") as Channel; const guildId = interaction.guildId; if (guildId == null) return await interaction.editReply("알수없는 서버에요!"); try { await removeGuildReadChannel(guildId, channel.id); } catch { return await interaction.editReply("읽지 않는것을 실패했어요 ?ㄴ"); } await interaction.editReply("예주가 이제 이 채널을 읽지않아요!"); }, true )