aboutsummaryrefslogtreecommitdiff
path: root/music.js
blob: c182a5e996032a00982cf5f033b4740488b7fdd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const ytdl = require("ytdl-core")
const voice = require("@discordjs/voice")

module.exports = {
	play: {
		func: (msg, url) => {
			const channel = msg.member.voice.channel

			if (! channel)
				return msg.reply("Join a voice channel you fucking moron")

			const conn = voice.joinVoiceChannel({
				channelId: channel.id,
				guildId: channel.guild.id,
				adapterCreator: channel.guild.voiceAdapterCreator,
			})
			const player = voice.createAudioPlayer()

			player.play(voice.createAudioResource(ytdl(url.join(" "), {filter: "audioonly"}), {inputType: voice.StreamType.Arbitrary}))
			conn.subscribe(player)
		}
	}
}