From da53c24febfac138a0c80397fa05c5dde67712dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Fri, 28 Jun 2019 03:50:16 +0200 Subject: [PATCH] made it better --- event/listeners/messageReactionAdd.js | 28 ++++++++++----------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 449fe2c3..32f9c2ed 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -1,8 +1,9 @@ const { Listener } = require('discord-akairo'); const { MessageEmbed } = require('discord.js'); -const reload = require('auto-reload'); +const fs = require('fs'); let messageID = require('../../json/starboard.json'); + class MessageReactionAddListener extends Listener { constructor() { super('messagereactionadd', { @@ -13,30 +14,21 @@ class MessageReactionAddListener extends Listener { async exec(reaction, user) { if (reaction.message.author == user) return; - - let messageContent = reaction.message.content; - let messageAttachments = reaction.message.attachments.map(u=> u.url); - - let starboardChannel, staremote, starcount, shameboardChannel, shameemote, shamecount; - - try { - starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`); - + let starboardChannel, shameboardChannel, staremote, starcount, shameemote, shamecount; + if (fs.existsSync(`./board/star${reaction.message.guild.id}.json`)) { + starboardChannel = require(`../../board/star${reaction.message.guild.id}.json`); staremote = starboardChannel['emote']; starcount = starboardChannel['count']; - } catch (err) { - console.log(`No shameboard for ${reaction.message.guild.name}, not an error`); } - - try { - shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`); - + if (fs.existsSync(`./board/shame${reaction.message.guild.id}.json`)) { + shameboardChannel = require(`../../board/shame${reaction.message.guild.id}.json`); shameemote = shameboardChannel['emote']; shamecount = shameboardChannel['count']; - } catch (err) { - console.log(`No shameboard for ${reaction.message.guild.name}, not an error`); } + let messageContent = reaction.message.content; + let messageAttachments = reaction.message.attachments.map(u=> u.url); + // Starboard if (reaction.emoji.name == staremote && reaction.count == starcount) { if (messageID.includes(reaction.message.id))