42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import {
|
|
type Channel,
|
|
ChannelType,
|
|
ChatInputCommandInteraction,
|
|
MessageFlags,
|
|
SlashCommandSubcommandBuilder,
|
|
} from "discord.js";
|
|
import { defineCommand } from "../command";
|
|
import { 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,
|
|
);
|