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
16 const channel = msg.member.voice.channel
19 return msg.reply("Join a voice channel you fucking moron")
21 const conn = voice.joinVoiceChannel({
22 channelId: channel.id,
23 guildId: channel.guild.id,
24 adapterCreator: channel.guild.voiceAdapterCreator,
26 const player = voice.createAudioPlayer()
28 player.play(voice.createAudioResource(ytdl(url, {filter: "audioonly"}), {inputType: voice.StreamType.Arbitrary}))
29 conn.subscribe(player)