This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+20 -11
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const moment = require('moment');
module.exports = class StarCommand extends Command {
@@ -24,23 +25,31 @@ module.exports = class StarCommand extends Command {
async run(msg, args, reaction) {
const { id } = args;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
if (!channel || !channel.permissionsFor(this.client.user).has(['SEND_MESSAGES', 'EMBED_LINKS'])) return null;
if (this.starred.includes(id)) return null;
try {
const message = await msg.channel.fetchMessage(id);
if (!reaction && msg.author.id === message.author.id)
return msg.reply('You cannot star your own messages, baka.');
if (!channel || this.starred.includes(id)) {
return null;
} else if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('I do not have Permission to send the message.');
}
const message = await msg.channel.fetchMessage(id);
if (!reaction && msg.author.id === message.author.id) {
return msg.reply('You cannot star your own messages, baka.');
}
this.starred.push(id);
if (!channel.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return msg.say(stripIndents`
**Author:** ${message.author.tag}
**Content:** ${message.content}
**Date:** ${moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')}
${message.attachments.first() ? `**Image:** ${message.attachments.first().url}` : ''}
`);
} else {
const embed = new RichEmbed()
.setColor(0xFFFF00)
.setAuthor(message.author.tag, message.author.displayAvatarURL)
.setDescription(message.content)
.setImage(message.attachments.first() ? message.attachments.first().url : null)
.setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A'));
this.starred.push(id);
await channel.send({ embed });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
return channel.send({ embed });
}
}
};