]> git.lizzy.rs Git - furrybot-discord.git/blob - music.js
Add music command
[furrybot-discord.git] / music.js
1 const ytdl = require("ytdl-core")
2 const voice = require("@discordjs/voice")
3
4 module.exports = {
5         play: {
6                 func: (msg, url) => {
7                         const channel = msg.member.voice.channel
8                         
9                         if (! channel)
10                                 return msg.reply("Join a voice channel you fucking moron")
11
12                         const conn = voice.joinVoiceChannel({
13                                 channelId: channel.id,
14                                 guildId: channel.guild.id,
15                                 adapterCreator: channel.guild.voiceAdapterCreator,
16                         })
17                 
18                         const stream = ytdl(url.join(" "), {filter: "audioonly"})
19                         const resource = voice.createAudioResource(stream, {inputType: voice.StreamType.Arbitrary})
20                         const player = voice.createAudioPlayer()
21                                 
22                         player.play(resource)
23                         conn.subscribe(player)
24                 }
25         }
26 }