all repos — simple-discord-music-bot @ 5fded05bd1b192407fad78e1406f688388b5f62e

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

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}