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 { 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))