src/functions/voice.ts (view raw)
1import { ChatInputCommandInteraction, VoiceBasedChannel } from 'discord.js'
2
3export async function getChannel(interaction: ChatInputCommandInteraction): Promise<string | VoiceBasedChannel>{
4 const member = interaction.member;
5 if (!member)
6 return 'Please use this in your current server.';
7
8 const vc_error = 'You\'re not in a voice channel.';
9
10 if (!("voice" in member)) return vc_error;
11 const channel: VoiceBasedChannel = member.voice.channel;
12 return channel ? channel : vc_error;
13}