From b194b8011ca173d15aa72bd83b6dc95d5316e60d Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 15 Feb 2019 01:09:08 +0100 Subject: [PATCH] dosen't throw error --- commands/admin/starboard.js | 1 - event/listeners/messageReactionAdd.js | 29 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/commands/admin/starboard.js b/commands/admin/starboard.js index 0accf757..2cf61cd7 100644 --- a/commands/admin/starboard.js +++ b/commands/admin/starboard.js @@ -29,7 +29,6 @@ class StarBoardCommand extends Command { } async exec(message, args) { - console.log(args); let starboardChannel = message.channel.id; fs.writeFile(`./board/star${message.guild.id}.json`, `{"starboard": "${starboardChannel}", "emote": "${args.emote}", "count": "${args.count}"}`, function (err) { diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index c5d52ce3..ff51b6f5 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -14,10 +14,20 @@ class MessageReactionAddListener extends Listener { async exec(reaction) { let messageContent = reaction.message.content; let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`); - let starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`); - let staremote = starboardChannel['emote']; - let starcount = starboardChannel['count']; + let starboardChannel; + let staremote; + let starcount; + + try { + starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`); + + staremote = starboardChannel['emote']; + starcount = starboardChannel['count']; + } catch (err) { + return null; + } + // Starboard if (reaction.emoji.name == staremote && reaction.count == starcount) { @@ -41,11 +51,18 @@ class MessageReactionAddListener extends Listener { return channel.send(`in: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`); } + let shameboardChannel; + let shameemote; + let shamecount; + try { + shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`); - let shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`); + shameemote = shameboardChannel['emote']; + shamecount = shameboardChannel['count']; + } catch (err) { + return null; + } - let shameemote = shameboardChannel['emote']; - let shamecount = shameboardChannel['count']; //Shameboard