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