1 const ytdl = require("ytdl-core")
2 const voice = require("@discordjs/voice")
3 const youtubeSearchApi = require("youtube-search-api")
7 func: async (msg, urlArr) => {
8 let url = urlArr.join(" ")
13 url = "https://youtube.com/watch?v=" + (await youtubeSearchApi.GetListByKeyword(url, false, 1)).items[0].id
14 msg.reply("Playing this: " + url)
17 const channel = msg.member.voice.channel
20 return msg.reply("Join a voice channel you fucking moron")
22 const conn = voice.joinVoiceChannel({
23 channelId: channel.id,
24 guildId: channel.guild.id,
25 adapterCreator: channel.guild.voiceAdapterCreator,
27 const player = voice.createAudioPlayer()
29 player.play(voice.createAudioResource(ytdl(url, {filter: "audioonly"}), {inputType: voice.StreamType.Arbitrary}))
30 conn.subscribe(player)