yaejunyang/packages/bot/commands/leaveVoiceChannel.ts

27 lines
842 B
TypeScript

import {
ChatInputCommandInteraction,
MessageFlags,
SlashCommandBuilder,
} from "discord.js";
import { defineCommand } from "../command";
import { getVoiceConnection } from "@discordjs/voice";
export default defineCommand(
new SlashCommandBuilder().setName("퇴장").setDescription("예주가 퇴장해요"),
async (interaction: ChatInputCommandInteraction): Promise<any> => {
await interaction.deferReply({
flags: [MessageFlags.Ephemeral],
});
if (interaction.guild == null)
return interaction.editReply("올바르지 않은 서버에요");
const connection = getVoiceConnection(interaction.guild.id);
if (!connection)
return interaction.editReply("예주는 통화방에 존제하지 않아요");
connection.disconnect();
await interaction.editReply("퇴장했어요!");
},
);