1 |
rakin |
344 |
import { MessageAttachment, MessageReaction, TextChannel } from "discord.js"; |
2 |
rakin |
51 |
import MessageEmbed from "../client/MessageEmbed"; |
3 |
rakin |
226 |
import Service from "../utils/structures/Service"; |
4 |
rakin |
33 |
|
5 |
rakin |
226 |
export default class Starboard extends Service { |
6 |
rakin |
51 |
async handle(reaction: MessageReaction) { |
7 |
|
|
if (this.client.config.get('starboard').enabled) { |
8 |
|
|
let emoji = reaction.emoji.name; |
9 |
rakin |
33 |
|
10 |
rakin |
51 |
console.log(emoji); |
11 |
rakin |
33 |
|
12 |
rakin |
51 |
if (emoji === '⭐' && reaction.message.channel.id !== this.client.config.get('starboard').channel && reaction.count === this.client.config.get('starboard').reactions) { |
13 |
rakin |
33 |
try { |
14 |
rakin |
51 |
const channel = <TextChannel> await reaction.message.guild!.channels.fetch(this.client.config.get('starboard').channel); |
15 |
rakin |
33 |
|
16 |
|
|
let props = { |
17 |
|
|
embeds: reaction.message.embeds || [] |
18 |
rakin |
51 |
}; |
19 |
rakin |
33 |
|
20 |
|
|
const msg = await channel.send({ |
21 |
|
|
embeds: [ |
22 |
|
|
...props.embeds, |
23 |
|
|
new MessageEmbed() |
24 |
|
|
.setAuthor({ |
25 |
rakin |
51 |
name: reaction.message.author!.tag, |
26 |
|
|
iconURL: reaction.message.author!.displayAvatarURL(), |
27 |
rakin |
33 |
}) |
28 |
rakin |
51 |
.setDescription(reaction.message.content!) |
29 |
rakin |
33 |
.addField('URL', `[Click here](${reaction.message.url})`) |
30 |
|
|
.setTimestamp() |
31 |
|
|
.setFooter({ |
32 |
|
|
text: reaction.message.id + '' |
33 |
|
|
}) |
34 |
|
|
], |
35 |
|
|
files: reaction.message.attachments.map(a => { |
36 |
|
|
return { |
37 |
|
|
name: a.name, |
38 |
|
|
attachment: a.proxyURL |
39 |
rakin |
51 |
} as MessageAttachment |
40 |
rakin |
33 |
}) |
41 |
|
|
}); |
42 |
|
|
|
43 |
|
|
await msg.react('⭐'); |
44 |
|
|
} |
45 |
|
|
catch (e) { |
46 |
|
|
console.log(e); |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
} |
50 |
|
|
} |
51 |
|
|
}; |