1.1.8 • Published 4 years ago

discord-handler v1.1.8

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

Discord-error-handler

A lightweight managing package,which catches and save discord errors. Intelligent saving ways and good interface. Find every Bug in your Code!

If you need help feel free to join our discord server. We will provied you all help ☺

Download

You can download it from npm:

npm i discord-error-handler

Setting Up

First we include the module into the project (into your main bot file).

const handle = require("discord-error-handler");
const client = new Discord.Client();
client.error = new Map();  // do not rename here something, or else Dx 
client.logchannel = [ "Guild_id_of_error_log_channel","channelid_of_error_log_channel"] ;

Saving/ Logging Erorrs

Following examples assume that your Discord.Client is called client.

client.on('message', async message => {
	try{
  if (message.author.bot) return;
if(message.content === "!notwork") return message.chanel.send("ddd"); // the error here is "chanel" , the right thing would be "channel" ==> this will now send a message in the log channel.
//When the error happens again. It will not send the error again 
}catch(error){
handle.createrr(client, message.guild.id, message.content, error)
}
});

Get a Report of all Errors

if(message.content === "!report") return handle.report(client , message);

Catch Unhandeld Error

process.on('unhandledRejection', error => { 
handle.createrr(client,undefined, undefined, error)
});

Get Status of each Shards

//This Codes is just for sharded bots
if(message.content === "!status") return client.handle.status(client , message);

Whole Code

const Discord = require('discord.js');
const { prefix, token  , url} = require('./config.json');
const client = new Discord.Client();

const handle = require("discord-error-handler");
client.error = new Map(); 
client.logchannel = [ "Guild ID","error_logging_channel_id"] ; // save here your default prefix

client.once('ready', () => {
console.log('Ready! Logged in as ' + client.user.tag + " with Prefix: " + prefix);
});
client.on('message', async message => {
try{
if (message.author.bot) return;
if(message.content === "!start") return message.chanel.send("ddd"); ///create a error
if(message.content === "!report") return handle.report(client , message);
}catch(error){
handle.createrr(client, message.guild.id, message.content, error)
}
});
client.login(token);
process.on('unhandledRejection', error => { 
handle.createrr(client,undefined, undefined, error)
});

Have fun and feel free to contribute/suggest or contact me on my discord server or per dm on Meister#9667

Bugs, Glitches and Issues

If you encounter any problems feel free to open an issue in our github repository or join the discord server..