42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import {
|
|
type Channel,
|
|
ChannelType,
|
|
ChatInputCommandInteraction,
|
|
MessageFlags,
|
|
SlashCommandSubcommandBuilder,
|
|
} from "discord.js";
|
|
import { defineCommand } from "../command";
|
|
import { insertGuildReadChannel } 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 insertGuildReadChannel(guildId, channel.id);
|
|
} catch {
|
|
return await interaction.editReply("읽는대 너무 어려워요..");
|
|
}
|
|
|
|
await interaction.editReply("예주가 이제 이 채널을 읽어요!");
|
|
},
|
|
true,
|
|
);
|