mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Star Command
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { RichEmbed } = require('discord.js');
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = class StarCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'star',
|
||||
group: 'random',
|
||||
memberName: 'star',
|
||||
description: 'Stars a message.',
|
||||
args: [
|
||||
{
|
||||
key: 'id',
|
||||
prompt: 'What is the ID of the message you wish to star?',
|
||||
type: 'string',
|
||||
validate: id => {
|
||||
if (id.length === 18) return true;
|
||||
return 'Invalid ID.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args, reaction) {
|
||||
const { id } = args;
|
||||
const channel = msg.guild.settings.get('starboard');
|
||||
if (!channel || !channel.permissionsFor(this.client.user).has('EMBED_LINKS')) 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, idiot.');
|
||||
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'));
|
||||
return channel.send({ embed });
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user