Weeb-Devs/Laffey

Bug

Closed this issue · 6 comments

image
whenever using a cmd it is showing this and its better to use js command handler than ts

i'm not sure the problem is in the command handler. Cannot read property 'players' of undefined mean that there's no object at client.player. I see that lavalink node has been connected successfully but there's still no object. If you have tried it again and still found a problem, i'll use js instead of ts on all handlers or functions

i'm not sure the problem is in the command handler. Cannot read property 'players' of undefined mean that there's no object at client.player. I see that lavalink node has been connected successfully but there's still no object. If you have tried it again and still found a problem, i'll use js instead of ts on all handlers or functions

yup i tried it again and again same issue and about handler js is best most people dont know what ts really is so and if they want to edit it it might be difficult to them

i see. Alright i'll change all the ts files into js on this pull request #4 tomorrow, and i'll try to make the error shown fully because we can't see from which line the error came from. and also, you can try to use eval command to see if there are object inside client.player or not. you can try to do this
>>eval client.player
and if you see undefined, that's an error

no error in this
image

i see that there's players inside client.player object. hmm, so lets debug it first. In src/laffey.js, find this line

            try {
                if (LOG_USAGE) {
                    console.log(chalk.magenta(`[LOG] => [COMMANDS] ${message.author.tag} (${message.author.id}) : ${message.content}`))
                }
                await command.execute(message, args, this)
            } catch (err) {
                const errorEmbed = new MessageEmbed()
                    .setDescription(`I'm sorry, there was an error while executing **${command.name}**\n\`\`\`${err}\`\`\``)
                    .setColor(this.guilds.cache.get(message.guild.id).me.displayHexColor != '#000000' ? this.guilds.cache.get(message.guild.id).me.displayHexColor : '#00C7FF')
                message.channel.send(errorEmbed)
                this.logger.error(err)
            }

and change it to

            try {
                if (LOG_USAGE) {
                    console.log(chalk.magenta(`[LOG] => [COMMANDS] ${message.author.tag} (${message.author.id}) : ${message.content}`))
                }
                await command.execute(message, args, this)
            } catch (err) {
                const errorEmbed = new MessageEmbed()
                    .setDescription(`I'm sorry, there was an error while executing **${command.name}**\n\`\`\`${err}\`\`\``)
                    .setColor(this.guilds.cache.get(message.guild.id).me.displayHexColor != '#000000' ? this.guilds.cache.get(message.guild.id).me.displayHexColor : '#00C7FF')
                message.channel.send(errorEmbed)
                console.log(err)
            }

this will change this.logger.error(err) to console.log(err) because we want to know from which line it throw an error

its working fine after using the eval command.