Skip to content

Commit

Permalink
last fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon1320 committed Nov 1, 2018
1 parent 38a3597 commit fef0db7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const loadCommands = () => {

const commands = loadCommands().then(commands => commands).catch(error => botLogger.fatalError(`Error loading local scripts: ${error}`));

const client = new discord.Client();
let client = new discord.Client();

/*
client.on("channelCreate", channel => {
Expand Down Expand Up @@ -208,9 +208,22 @@ client.on("emojiUpdate", (oldEmoji, newEmoji) => {
// temp error handling
let lastMessage = null;

client.on("error", error => {
client.on("error", async error => {

console.error(`big boii error: ${JSON.stringify(error)}`);
console.error(new Date() + ": Discord client encountered an error");
console.error(error);

console.log("the bot may have crashed, attempting to restart...");

client = new discord.Client();

client.login(config.discord_token).then(() => {

botLogger.log("stdout", "logged into discord");
}).catch(error => {

console.error(error);
});
});
/*
client.on("guildBanAdd", (guild, user) => {
Expand Down

0 comments on commit fef0db7

Please sign in to comment.