From 8a14097c2d43dff0073d049dcabaa5d9b2761d5a Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 11 Jan 2019 12:21:05 +0100 Subject: [PATCH 1/3] fixed issue with starboard --- event/listeners/messageReactionAdd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index cc18c4e9..0a65f1b9 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -21,7 +21,7 @@ class MessageReactionAddListener extends Listener { messageID.push(reaction.message.id); - let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); + let starboardChannel = reload(`../../starboard/${reaction.message.guild.id}.json`); const channel = this.client.channels.get(starboardChannel['starboard']); const starEmbed = new MessageEmbed() @@ -39,7 +39,7 @@ class MessageReactionAddListener extends Listener { messageID.push(reaction.message.id); - let shameboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`); + let shameboardChannel = reload(`../../starboard/${reaction.message.guild.id}.json`); const channel = this.client.channels.get(shameboardChannel['shameboard']); const shameEmbed = new MessageEmbed() From d820bc6adf7e2b55f0f6c768e0488a2d27d4698b Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 11 Jan 2019 12:47:04 +0100 Subject: [PATCH 2/3] Fixed starboard? hopefully --- commands/admin/shameboard.js | 8 +++----- commands/admin/starboard.js | 9 ++++----- event/listeners/messageReactionAdd.js | 6 ++++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/commands/admin/shameboard.js b/commands/admin/shameboard.js index e3aa8c2d..fc4d84e7 100644 --- a/commands/admin/shameboard.js +++ b/commands/admin/shameboard.js @@ -19,20 +19,18 @@ class shameboardCommand extends Command { async exec(message) { let shameboardChannel = message.channel.id; - fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { + fs.readFile(`./board/shame${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { if (err) { - fs.writeFile(`./starboard/${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) { + fs.writeFile(`./board/shame${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) { if (err) { console.log(err); } - - return message.channel.send('This channel have been set as the shameboard'); }); } else { let shameboard = JSON.parse(data); //now it an object shameboard['shameboard'] = shameboardChannel; var json = JSON.stringify(shameboard); //convert it back to json - fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) { + fs.writeFile(`./board/shame${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { return console.log(err); diff --git a/commands/admin/starboard.js b/commands/admin/starboard.js index 7ceb2613..2be000d0 100644 --- a/commands/admin/starboard.js +++ b/commands/admin/starboard.js @@ -19,20 +19,19 @@ class StarBoardCommand extends Command { async exec(message) { let starboardChannel = message.channel.id; - fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { + fs.readFile(`./board/star${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) { if (err) { - fs.writeFile(`./starboard/${message.guild.id}.json`, `{"starboard": "${starboardChannel}"}`, function (err) { + console.log('yes'); + fs.writeFile(`./board/star${message.guild.id}.json`, `{"starboard": "${starboardChannel}"}`, function (err) { if (err) { console.log(err); } - - return message.channel.send('This channel have been set as the starboard'); }); } else { let starboard = JSON.parse(data); //now it an object starboard['starboard'] = starboardChannel; var json = JSON.stringify(starboard); //convert it back to json - fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) { + fs.writeFile(`./board/star${message.guild.id}.json`, json, 'utf8', function (err) { if (err) { return console.log(err); diff --git a/event/listeners/messageReactionAdd.js b/event/listeners/messageReactionAdd.js index 0a65f1b9..19d46499 100644 --- a/event/listeners/messageReactionAdd.js +++ b/event/listeners/messageReactionAdd.js @@ -15,13 +15,14 @@ class MessageReactionAddListener extends Listener { let messageContent = reaction.message.content; let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`); + // Starboard if (reaction.emoji.name === '🌟' && reaction.count === 4) { if (messageID.includes(reaction.message.id)) return console.log('Message already in starboard!'); messageID.push(reaction.message.id); - let starboardChannel = reload(`../../starboard/${reaction.message.guild.id}.json`); + let starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`); const channel = this.client.channels.get(starboardChannel['starboard']); const starEmbed = new MessageEmbed() @@ -33,13 +34,14 @@ class MessageReactionAddListener extends Listener { channel.send({ embed: starEmbed}); return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`); } + //Shameboard if (reaction.emoji.name === '✡' && reaction.count === 4) { if (messageID.includes(reaction.message.id)) return console.log('Message already in starboard!'); messageID.push(reaction.message.id); - let shameboardChannel = reload(`../../starboard/${reaction.message.guild.id}.json`); + let shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`); const channel = this.client.channels.get(shameboardChannel['shameboard']); const shameEmbed = new MessageEmbed() From f55e79e8f5a609702b91ff219e1ed70763b5f7ae Mon Sep 17 00:00:00 2001 From: loicbersier Date: Fri, 11 Jan 2019 23:04:13 +0100 Subject: [PATCH 3/3] Fixed autoresponse not working when no tag was set --- event/listeners/message.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index 162ba71a..600c53e3 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -15,15 +15,9 @@ class messageListener extends Listener { async exec(message) { let autoresponse = reload('../../json/autoresponse.json'); let message_content = message.content.toLowerCase(); - let customresponse = reload(`../../tag/${message.guild.id}.json`); if (message.author.bot) return; { - // User autoresponse - if(customresponse[message_content]) { - message.channel.send(customresponse[message_content]); - } - // If autoresponse is enable send the response if(autoresponse[message.channel.id] == 'enable') { // Reply with images as attachement @@ -44,6 +38,11 @@ class messageListener extends Listener { } else if (message_content.includes('jeff')) { message.react('496028845967802378'); } + } + // User autoresponse + let customresponse = reload(`../../tag/${message.guild.id}.json`); + if(customresponse[message_content]) { + message.channel.send(customresponse[message_content]); } } }