blob: 50bba47eb30c53f75e28e27e8786fb5b218edab4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
const ytdl = require("ytdl-core")
const voice = require("@discordjs/voice")
const youtubeSearchApi = require("youtube-search-api")
module.exports = {
play: {
func: async (msg, urlArr) => {
let url = urlArr.join(" ")
try {
new URL(url)
} catch {
url = "https://youtube.com/watch?v=" + (await youtubeSearchApi.GetListByKeyword(url, false, 1)).items[0].id
}
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, {filter: "audioonly"}), {inputType: voice.StreamType.Arbitrary}))
conn.subscribe(player)
}
}
}
|