all repos — simple-discord-music-bot @ 858558392fd3953294b6c45ca9951af53a9f1e27

A Discord bot making use of discord.js and play-yt.

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}