-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdashboard.js
More file actions
21 lines (20 loc) · 776 Bytes
/
Copy pathdashboard.js
File metadata and controls
21 lines (20 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const ytdl = require('ytdl-core')
const ytsr = require('ytsr')
const voice = require('@discordjs/voice')
const config = require("./config.json")
const {Client, Intents} = require('discord.js')
const client = new Client({intents: [Intents.FLAGS.GUILDS , Intents.FLAGS.GUILD_VOICE_STATES]})
client.login(config.token)
exports.Player = async function Player(opts){
ytsr(opts.query).then(data =>{
const player = voice.createAudioPlayer()
const connection = voice.joinVoiceChannel({
channelId: opts.channel,
guildId: opts.guild,
adapterCreator: client.guilds.cache.get(opts.guild).voiceAdapterCreator
})
const resource = voice.createAudioResource(ytdl(data.items[0].url))
player.play(resource)
connection.subscribe(player)
})
}