koibot/src/commands/start.ts

43 lines
1.1 KiB
TypeScript

import {
APIChatInputApplicationCommandInteraction,
WithIntrinsicProps,
} from "@discordjs/core"
import {
client,
gateway,
rest,
sessionManager,
voiceStateManager,
} from "../api.js"
import { Routes } from "discord-api-types/v10"
import { joinVoiceChannel } from "@discordjs/voice"
export const startCommand = async ({
data,
api,
shardId,
}: WithIntrinsicProps<APIChatInputApplicationCommandInteraction>) => {
if (!data.member || !data.guild_id)
return api.interactions.reply(data.id, data.token, {
content: "이 명령어는 서버에서 사용되어야 해요!",
})
if (sessionManager.hasSession(data.guild_id))
return api.interactions.reply(data.id, data.token, {
content: "이미 이 서버에서는 녹음이 진행중이에요!",
})
const vc = voiceStateManager.getUserVC(data.guild_id, data.member.user.id)
if (!vc)
return api.interactions.reply(data.id, data.token, {
content: "먼저 음성 채널에 들어가주세요!",
})
await sessionManager.addSession(data.guild_id, vc, data.channel_id, shardId)
await api.interactions.reply(data.id, data.token, {
content: "냥냥",
})
}