Discord-MusicBot
                                
                                
                                
                                    Discord-MusicBot copied to clipboard
                            
                            
                            
                        error handling
Added error handling
Please describe the changes this PR makes and why it should be merged: Because its missing from the debug option
Status and versioning classification:
Added logging to errors and warning when DEBUG mode is enabled.
@SudhanPlayz fixed
I'm going to test this
apparently, this commit still don't solve the issue with the error handling
Well, if It works for me it works for me. You are on a phone, on replit. Did you even try to produce a warning? All you showed is your console.
hello! i'm here to inform you that this error is rate limiting, there is no problem where you run the code. basically this is how it worked for you.
you waited long enough and the rate limit has been lifted so that's why you can login again
discord.js is not outputting error with this matter, so that's why it's kinda confusing in first not seeing your bot login, also the
process.on("warning")
is irrelevant since we're not using the --no-warnings and the warnings will be shown as usual
so tl;dr the current debug mode is already fine, there's some errors you can't see, and i thought this changes it but nah it still doesn't. in my experience with v5, debug mode is outputting the errors i need
so tl;dr the current debug mode is already fine, there's some errors you can't see, and i thought this changes it but nah it still doesn't. in my experience with v5, debug mode is outputting the errors i need
To be honest, you could just use a dedicated anticrash file for this which would be much more better for developers actively contributing to this project, tons of anticrash.js files are available on the internet and I've written my own below:
const chalk = require("chalk"); // Importing Chalk from Chalk
const { MessageEmbed, WebhookClient } = require('discord.js') // Importing MessageEmbed from Discord.js
const { inspect } = require("util");
const s = new WebhookClient({
                id: "id",
                token:"token",
            });
//not using normal client.channels.cache.get("id") functions as it returns bunch of errors.
module.exports = (client) => {
client.on('error', err => {
        // const a = client.channels.cache.get(config.ERROR_LOG_CHANNEL)
        console.log(err)
        const ErrorEmbed = new MessageEmbed()
            .setTitle('Error')
            .setURL('https://discordjs.guide/popular-topics/errors.html#api-errors')
            .setColor('#2F3136')
            .setDescription(`\`\`\`${inspect(error, {depth: 0})}\`\`\``)
            .setTimestamp()
        return s.send({
            embeds: [ErrorEmbed]
        })
    });
    process.on("unhandledRejection", (reason, p) => {
        console.log(
            chalk.yellow('[Anticrash] Unhandled Rejection\n'),
            reason, p
        )
        const unhandledRejectionEmbed = new MessageEmbed()
            .setTitle('**[Anticrash] Unhandled Rejection**')
            .setURL('https://nodejs.org/api/process.html#event-unhandledrejection')
            .setColor("#FF5555")
            .addField('Reason', `\`\`\`js\n${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000))
            .addField('Promise', `\`\`\`js\n${inspect(p, { depth: 0 })}\`\`\``.substring(0, 1000))
            .setTimestamp()
        return s.send({
            embeds: [unhandledRejectionEmbed]
        })
    });
    
    process.on("uncaughtException", (err, origin) => {
        console.log(err, origin)
        const uncaughtExceptionEmbed = new MessageEmbed()
            .setTitle('**[Anticrash] Uncaught Exception**')
            .setColor("#FF5555")
            .setURL('https://nodejs.org/api/process.html#event-uncaughtexception')
            .addField('Error', `\`\`\`js\n${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000))
            .addField('Origin', `\`\`\`js\n${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000))
            .setTimestamp()
        return s.send({
            embeds: [uncaughtExceptionEmbed]
        })
    });
    
    process.on("uncaughtExceptionMonitor", (err, origin) => {
        console.log(err, origin)
        const xd = new MessageEmbed()
            .setTitle('**[Anticrash] Uncaught Exception Monitor*')
            .setColor("#FF5555")
            .setURL('https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor')
            .addField('Error', `\`\`\`js\n${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000))
            .addField('Origin', `\`\`\`js\n${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000))
            .setTimestamp();
          return s.send({
            embeds: [xd]
        })
    });
    
    process.on("multipleResolves", (type, promise, reason) => {
        console.log(type, promise, reason)
        const multipleResolvesEmbed = new MessageEmbed()
            .setTitle('**[Anticrash] Multiple Resolves**')
            .setURL('https://nodejs.org/api/process.html#event-multipleresolves')
            .setColor("#FF5555")
            .addField('Type', `\`\`\`js\n${inspect(type, { depth: 0 })}\`\`\``.substring(0, 1000))
            .addField('Promise', `\`\`\`js\n${inspect(promise, { depth: 0 })}\`\`\``.substring(0, 1000))
            .addField('Reason', `\`\`\`js\n${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000))
            .setTimestamp()
        return s.send({
            embeds: [multipleResolvesEmbed]
        })
    });
}
                                    
                                    
                                    
                                
so tl;dr the current debug mode is already fine, there's some errors you can't see, and i thought this changes it but nah it still doesn't. in my experience with v5, debug mode is outputting the errors i need
To be honest, you could just use a dedicated anticrash file for this which would be much more better for developers actively contributing to this project, tons of anticrash.js files are available on the internet and I've written my own below:
const chalk = require("chalk"); // Importing Chalk from Chalk const { MessageEmbed, WebhookClient } = require('discord.js') // Importing MessageEmbed from Discord.js const { inspect } = require("util"); const s = new WebhookClient({ id: "id", token:"token", }); //not using normal client.channels.cache.get("id") functions as it returns bunch of errors. module.exports = (client) => { client.on('error', err => { // const a = client.channels.cache.get(config.ERROR_LOG_CHANNEL) console.log(err) const ErrorEmbed = new MessageEmbed() .setTitle('Error') .setURL('https://discordjs.guide/popular-topics/errors.html#api-errors') .setColor('#2F3136') .setDescription(`\`\`\`${inspect(error, {depth: 0})}\`\`\``) .setTimestamp() return s.send({ embeds: [ErrorEmbed] }) }); process.on("unhandledRejection", (reason, p) => { console.log( chalk.yellow('[Anticrash] Unhandled Rejection\n'), reason, p ) const unhandledRejectionEmbed = new MessageEmbed() .setTitle('**[Anticrash] Unhandled Rejection**') .setURL('https://nodejs.org/api/process.html#event-unhandledrejection') .setColor("#FF5555") .addField('Reason', `\`\`\`js\n${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000)) .addField('Promise', `\`\`\`js\n${inspect(p, { depth: 0 })}\`\`\``.substring(0, 1000)) .setTimestamp() return s.send({ embeds: [unhandledRejectionEmbed] }) }); process.on("uncaughtException", (err, origin) => { console.log(err, origin) const uncaughtExceptionEmbed = new MessageEmbed() .setTitle('**[Anticrash] Uncaught Exception**') .setColor("#FF5555") .setURL('https://nodejs.org/api/process.html#event-uncaughtexception') .addField('Error', `\`\`\`js\n${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000)) .addField('Origin', `\`\`\`js\n${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000)) .setTimestamp() return s.send({ embeds: [uncaughtExceptionEmbed] }) }); process.on("uncaughtExceptionMonitor", (err, origin) => { console.log(err, origin) const xd = new MessageEmbed() .setTitle('**[Anticrash] Uncaught Exception Monitor*') .setColor("#FF5555") .setURL('https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor') .addField('Error', `\`\`\`js\n${inspect(err, { depth: 0 })}\`\`\``.substring(0, 1000)) .addField('Origin', `\`\`\`js\n${inspect(origin, { depth: 0 })}\`\`\``.substring(0, 1000)) .setTimestamp(); return s.send({ embeds: [xd] }) }); process.on("multipleResolves", (type, promise, reason) => { console.log(type, promise, reason) const multipleResolvesEmbed = new MessageEmbed() .setTitle('**[Anticrash] Multiple Resolves**') .setURL('https://nodejs.org/api/process.html#event-multipleresolves') .setColor("#FF5555") .addField('Type', `\`\`\`js\n${inspect(type, { depth: 0 })}\`\`\``.substring(0, 1000)) .addField('Promise', `\`\`\`js\n${inspect(promise, { depth: 0 })}\`\`\``.substring(0, 1000)) .addField('Reason', `\`\`\`js\n${inspect(reason, { depth: 0 })}\`\`\``.substring(0, 1000)) .setTimestamp() return s.send({ embeds: [multipleResolvesEmbed] }) }); }
PS: You need to add: ``` js require("..events/anticrash") (client); in the index.js file!
                                    
                                    
                                    
                                
You know what, you guys keep arguing with me, disrespectful. Im not going to continue this pull request.
You know what, you guys keep arguing with me, disrespectful. Im not going to continue this pull request.
.... w h a t
tf