So, i have this code:
client.on('messageCreate', async msg => {
if (msg.content.startsWith('-p')) {
if (!msg.member.voice?.channel) return msg.channel.send('Por favor...')
const connection = joinVoiceChannel({
channelId: msg.member.voice.channel.id,
guildId: msg.guild.id,
adapterCreator: msg.guild.voiceAdapterCreator
})
google.youtube('v3').search.list({
key: process.env.YOUTUBE_TOKEN,
part: 'id',
q: msg.content.slice(3),
maxResults: 1
}).then((response) => {
const { data } = response;
let link = 'https://www.youtube.com/watch?v=' + data.items.id.videoId
})
let args = msg.content.slice(3)
let stream = await play.stream(args)
let resource = createAudioResource(stream.stream, {
inputType: stream.type
})
let player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Play
}
})
player.play(resource)
connection.subscribe(player)
}
})
And i would like to use the value of the variable "link", which is a string, as parameter for the method play.stre(args)
I'm don't fully understand how to get that done
Also, if possible i would like to find a way to store that value too inside an array outside the whole:
*client.on('messageCreate' , async msg => {... ...})*
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment