src/functions/music.ts (view raw)
1import { ChatInputCommandInteraction, VoiceBasedChannel } from 'discord.js'
2import { YouTubeVideo } from 'play-dl';
3import MyQueue from './myqueue';
4
5export const queue = new MyQueue();
6
7export function formatTitle(video: YouTubeVideo): string {
8 return `**${video.title}** (\`${video.durationRaw}\`)`
9}
10
11export async function getChannel(interaction: ChatInputCommandInteraction): Promise<string | VoiceBasedChannel>{
12 const member = interaction.member;
13 if (!member)
14 return 'Please use this in your current server.';
15
16 const vc_error = 'You\'re not in a voice channel.';
17
18 if (!("voice" in member)) return vc_error;
19 const channel: VoiceBasedChannel = member.voice.channel;
20 return channel ? channel : vc_error;
21}