I am pretty sure it means message is not defined but why I think I defined it does anyone know what is the problem? I tried everything I can. it sends this error (There was an error connecting to the voice channel: TypeError: Cannot read property 'react' of undefined)
function play(guild, song, client, message) {
const serverQueue = client.queue.get(guild.id)
const loop = client.loop.get(guild.id)
console.log(loop)
if (!song) {
serverQueue.voiceChannel.leave()
client.queue.delete(guild.id)
return
}
const dispatcher = serverQueue.connection.play(ytdl(song.url))
.on('finish', () => {
if (loop === undefined) {
serverQueue.songs.shift()
}
play(guild, serverQueue.songs[0], client, message)
})
.on('error', error => {
console.log(error)
})
dispatcher.setVolumeLogarithmic(serverQueue.volume / 5)
if (loop === undefined) {
const reaction = (reaction) => reaction.emoji.name === '⏭️';
serverQueue.textChannel.send(`Playing: **${song.title}**`)
message.react('⏭️')
.then(console.log)
.catch(console.error);
message.awaitReactions((reaction) => (reaction.emoji.name == '⏭️'),
{ max: 1 }).then(collected => {
if (collected.first().emoji.name == '⏭️') {
if(!message.member.voice.channel) return message.channel.send("You need to be in a voice channel to skip the music")
if(!serverQueue) return message.channel.send("There is nothing to playing")
serverQueue.connection.dispatcher.end()
client.loop.delete(message.guild.id)
}
return undefined
})
}
}
You are right. Inside play(<args>){...}
function you try to call .react()
on undefined
. Could you give more context to this problem? Like the calling context to see why play(<args>){}
receives no value for its 4th parameter, message.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.