From dd16ffe945e710803e67855f668c40e16e4d451e Mon Sep 17 00:00:00 2001 From: kimpure Date: Mon, 23 Feb 2026 11:21:48 +0000 Subject: [PATCH] Add skip current command --- packages/bot/commands/skipCurrent.ts | 25 +++++++++++++++++++++++++ packages/bot/tts.ts | 22 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 packages/bot/commands/skipCurrent.ts diff --git a/packages/bot/commands/skipCurrent.ts b/packages/bot/commands/skipCurrent.ts new file mode 100644 index 0000000..93a44aa --- /dev/null +++ b/packages/bot/commands/skipCurrent.ts @@ -0,0 +1,25 @@ +import { ChatInputCommandInteraction, MessageFlags, SlashCommandBuilder } from "discord.js"; +import { defineCommand } from "../command"; +import { skipCurrentVoice } from "../tts"; + +export default defineCommand( + new SlashCommandBuilder() + .setName("스킵") + .setDescription("실행중인 보이스를 건너뜁니다"), + async (interaction: ChatInputCommandInteraction): Promise => { + await interaction.deferReply({ + flags: [MessageFlags.Ephemeral] + }); + + if (!interaction.guild) { + await interaction.editReply("서버에서만 사용할 수 있어요"); + return; + } + + if (await skipCurrentVoice(interaction.guild)) { + await interaction.editReply("스킵 되었어요"); + } else { + await interaction.editReply("실행중인 보이스가 없어요"); + } + } +) \ No newline at end of file diff --git a/packages/bot/tts.ts b/packages/bot/tts.ts index d661cb8..6ff71e3 100644 --- a/packages/bot/tts.ts +++ b/packages/bot/tts.ts @@ -1,4 +1,4 @@ -import { AudioPlayerStatus, AudioResource, createAudioPlayer, VoiceConnection } from "@discordjs/voice"; +import { AudioPlayer, AudioPlayerStatus, AudioResource, createAudioPlayer, VoiceConnection } from "@discordjs/voice"; import { Voice } from "../db/generated/prisma/enums"; import TTSTypecastModel from "../tts/typecast"; import TTSPapagoModel from "../tts/papago"; @@ -35,6 +35,7 @@ export async function createVoiceBuffer(voice: Voice, text: string): Promise { + let connection = await getOrCreateVoiceConnection(guild); + if (!connection) + throw new Error("Yaeju is not joined VoiceChat"); + + const vqueue = VoiceQueue.fromConnection(connection); + if (vqueue.hasNext()) { + vqueue.next(); + return true; + } + return false; +}