made it better

This commit is contained in:
Loïc Bersier 2019-06-28 03:50:16 +02:00
parent 021051e6a3
commit da53c24feb

View file

@ -1,8 +1,9 @@
const { Listener } = require('discord-akairo'); const { Listener } = require('discord-akairo');
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const reload = require('auto-reload'); const fs = require('fs');
let messageID = require('../../json/starboard.json'); let messageID = require('../../json/starboard.json');
class MessageReactionAddListener extends Listener { class MessageReactionAddListener extends Listener {
constructor() { constructor() {
super('messagereactionadd', { super('messagereactionadd', {
@ -13,30 +14,21 @@ class MessageReactionAddListener extends Listener {
async exec(reaction, user) { async exec(reaction, user) {
if (reaction.message.author == user) return; if (reaction.message.author == user) return;
let starboardChannel, shameboardChannel, staremote, starcount, shameemote, shamecount;
let messageContent = reaction.message.content; if (fs.existsSync(`./board/star${reaction.message.guild.id}.json`)) {
let messageAttachments = reaction.message.attachments.map(u=> u.url); starboardChannel = require(`../../board/star${reaction.message.guild.id}.json`);
let starboardChannel, staremote, starcount, shameboardChannel, shameemote, shamecount;
try {
starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`);
staremote = starboardChannel['emote']; staremote = starboardChannel['emote'];
starcount = starboardChannel['count']; starcount = starboardChannel['count'];
} catch (err) {
console.log(`No shameboard for ${reaction.message.guild.name}, not an error`);
} }
if (fs.existsSync(`./board/shame${reaction.message.guild.id}.json`)) {
try { shameboardChannel = require(`../../board/shame${reaction.message.guild.id}.json`);
shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`);
shameemote = shameboardChannel['emote']; shameemote = shameboardChannel['emote'];
shamecount = shameboardChannel['count']; 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 // Starboard
if (reaction.emoji.name == staremote && reaction.count == starcount) { if (reaction.emoji.name == staremote && reaction.count == starcount) {
if (messageID.includes(reaction.message.id)) if (messageID.includes(reaction.message.id))