yaejunyang/packages/bot/commands/unreadChannel.ts

36 lines
No EOL
1.4 KiB
TypeScript

import { Channel, ChannelType, 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")
.addChannelTypes(ChannelType.GuildText, ChannelType.GuildVoice)
.setDescription("예주가 더이상 읽지 않을 채널이에요")
.setRequired(true)
),
async (interaction: ChatInputCommandInteraction): Promise<any> => {
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(`예주가 <#${channel.id}> 채널을 읽지않아요!`);
},
true
)