56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import {
|
|
type Channel,
|
|
ChannelType,
|
|
ChatInputCommandInteraction,
|
|
GuildMember,
|
|
MessageFlags,
|
|
SlashCommandBuilder,
|
|
} from "discord.js";
|
|
import { defineCommand } from "../command";
|
|
import { joinVoiceChannel } from "@discordjs/voice";
|
|
|
|
export default defineCommand(
|
|
new SlashCommandBuilder()
|
|
.setName("등장")
|
|
.setDescription("예주가 등장해요")
|
|
.addChannelOption((option) =>
|
|
option
|
|
.setName("channel")
|
|
.setDescription("예주가 등장할 채널이에요")
|
|
.addChannelTypes(ChannelType.GuildVoice),
|
|
),
|
|
async (interaction: ChatInputCommandInteraction): Promise<any> => {
|
|
await interaction.deferReply({
|
|
flags: [MessageFlags.Ephemeral],
|
|
});
|
|
|
|
const member = interaction.member as GuildMember | null;
|
|
if (member == null) return;
|
|
|
|
if (interaction.guild == null)
|
|
return interaction.reply({
|
|
content: "올바르지 않은 서버에요",
|
|
ephemeral: true,
|
|
});
|
|
|
|
const channel =
|
|
(interaction.options.getChannel("channel") as Channel) ||
|
|
member.voice.channel;
|
|
|
|
if (channel == null)
|
|
return interaction.reply({
|
|
content: "통화방에 들어가거나 채널을 지정해주세요!",
|
|
ephemeral: true,
|
|
});
|
|
|
|
joinVoiceChannel({
|
|
channelId: channel.id,
|
|
guildId: interaction.guild.id,
|
|
adapterCreator: interaction.guild.voiceAdapterCreator,
|
|
selfDeaf: false,
|
|
selfMute: false,
|
|
});
|
|
|
|
await interaction.editReply("등장했어요!");
|
|
},
|
|
);
|