yaejunyang/packages/bot/commands/playVoice.ts
2026-02-23 11:33:46 +00:00

38 lines
No EOL
1.3 KiB
TypeScript

import { ChatInputCommandInteraction, MessageFlags, SlashCommandSubcommandBuilder } from "discord.js";
import { defineCommand } from "../command";
import { playVoice } from "../tts";
import { getUserProfile } from "../db";
export default defineCommand(
new SlashCommandSubcommandBuilder()
.setName("말")
.setDescription("구구가가")
.addStringOption(option =>
option
.setName("content")
.setDescription("예주가 말해준데요")
.setRequired(true)
),
async (interaction: ChatInputCommandInteraction): Promise<any> => {
await interaction.deferReply({
flags: [MessageFlags.Ephemeral]
});
if (interaction.guild == null)
return await interaction.editReply("올바르지 않은 서버에요");
try {
const userProfile = await getUserProfile(interaction.user.id);
await playVoice(
interaction.guild,
userProfile,
userProfile.voice,
interaction.options.getString("content") as string
);
await interaction.editReply("말했어요!");
} catch {
await interaction.editReply("오늘따라 말이 꼬이네요 ㅜ.ㅜ");
}
}
)