Haha-Yes/listeners/messageReactionAdd.js

57 lines
2 KiB
JavaScript
Raw Normal View History

2019-01-01 03:49:46 +01:00
const { Listener } = require('discord-akairo');
const { MessageEmbed } = require('discord.js');
const reload = require('auto-reload');
let messageID = require('../json/starboard.json');
2019-01-01 03:49:46 +01:00
class MessageReactionAddListener extends Listener {
2019-01-02 08:09:45 +01:00
constructor() {
super('messagereactionadd', {
emitter: 'client',
2019-01-02 21:46:12 +01:00
event: 'messageReactionAdd'
2019-01-02 08:09:45 +01:00
});
}
2019-01-03 23:24:13 +01:00
async exec(reaction) {
2019-01-02 08:09:45 +01:00
let messageContent = reaction.message.content;
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
2019-01-03 23:24:13 +01:00
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);
2019-01-02 08:09:45 +01:00
let starboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`);
const channel = this.client.channels.get(starboardChannel['starboard']);
const starEmbed = new MessageEmbed()
2019-01-04 19:43:10 +01:00
.setColor(reaction.message.member.displayHexColor)
.setDescription(messageContent)
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp();
2019-01-02 08:09:45 +01:00
channel.send({ embed: starEmbed});
return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`);
2019-01-02 08:09:45 +01:00
}
2019-01-04 19:46:19 +01:00
if (reaction.emoji.name === '✡' && reaction.count === 4) {
if (messageID.includes(reaction.message.id))
return console.log('Message already in starboard!');
2019-01-03 17:52:54 +01:00
messageID.push(reaction.message.id);
2019-01-03 17:52:54 +01:00
let shameboardChannel = reload(`../starboard/${reaction.message.guild.id}.json`);
const channel = this.client.channels.get(shameboardChannel['shameboard']);
2019-01-02 08:09:45 +01:00
2019-01-03 17:52:54 +01:00
const shameEmbed = new MessageEmbed()
2019-01-04 19:43:10 +01:00
.setColor(reaction.message.member.displayHexColor)
.setDescription(messageContent)
2019-01-04 19:43:10 +01:00
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL)
.setTimestamp();
2019-01-02 08:09:45 +01:00
2019-01-03 17:52:54 +01:00
channel.send({ embed: shameEmbed});
return channel.send(`From: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`);
2019-01-02 08:09:45 +01:00
}
}
2019-01-01 03:49:46 +01:00
}
module.exports = MessageReactionAddListener;