1 |
const MessageEmbed = require("../src/MessageEmbed"); |
import { MessageAttachment, MessageReaction, TextChannel, User } from "discord.js"; |
2 |
|
import DiscordClient from "../client/Client"; |
3 |
|
import MessageEmbed from "../client/MessageEmbed"; |
4 |
|
|
5 |
module.exports = class Starboard { |
export default class Starboard { |
6 |
async handle(reaction, user) { |
constructor(private client: DiscordClient) { |
|
if (app.config.get('starboard').enabled) { |
|
|
let emoji; |
|
7 |
|
|
8 |
if (typeof reaction._emoji !== 'undefined') |
} |
9 |
emoji = reaction._emoji.name; |
|
10 |
else |
async handle(reaction: MessageReaction) { |
11 |
emoji = reaction.anme; |
if (this.client.config.get('starboard').enabled) { |
12 |
|
let emoji = reaction.emoji.name; |
13 |
|
|
14 |
console.log(reaction, emoji); |
console.log(emoji); |
15 |
|
|
16 |
if (emoji === '⭐' && reaction.message.channel.id !== app.config.get('starboard').channel && reaction.count === app.config.get('starboard').messages) { |
if (emoji === '⭐' && reaction.message.channel.id !== this.client.config.get('starboard').channel && reaction.count === this.client.config.get('starboard').reactions) { |
17 |
try { |
try { |
18 |
const channel = await reaction.message.guild.channels.fetch(app.config.get('starboard').channel); |
const channel = <TextChannel> await reaction.message.guild!.channels.fetch(this.client.config.get('starboard').channel); |
19 |
|
|
20 |
let props = { |
let props = { |
21 |
embeds: reaction.message.embeds || [] |
embeds: reaction.message.embeds || [] |
22 |
} |
}; |
23 |
|
|
24 |
const msg = await channel.send({ |
const msg = await channel.send({ |
25 |
embeds: [ |
embeds: [ |
26 |
...props.embeds, |
...props.embeds, |
27 |
new MessageEmbed() |
new MessageEmbed() |
28 |
.setAuthor({ |
.setAuthor({ |
29 |
name: reaction.message.author.tag, |
name: reaction.message.author!.tag, |
30 |
iconURL: reaction.message.author.displayAvatarURL(), |
iconURL: reaction.message.author!.displayAvatarURL(), |
31 |
}) |
}) |
32 |
.setDescription(reaction.message.content) |
.setDescription(reaction.message.content!) |
33 |
.addField('URL', `[Click here](${reaction.message.url})`) |
.addField('URL', `[Click here](${reaction.message.url})`) |
34 |
.setTimestamp() |
.setTimestamp() |
35 |
.setFooter({ |
.setFooter({ |
40 |
return { |
return { |
41 |
name: a.name, |
name: a.name, |
42 |
attachment: a.proxyURL |
attachment: a.proxyURL |
43 |
} |
} as MessageAttachment |
44 |
}) |
}) |
45 |
}); |
}); |
46 |
|
|