/[sudobot]/branches/2.x/src/services/Starboard.ts
ViewVC logotype

Annotation of /branches/2.x/src/services/Starboard.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 2208 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import { MessageAttachment, MessageReaction, TextChannel, User } from "discord.js";
2     import DiscordClient from "../client/Client";
3     import MessageEmbed from "../client/MessageEmbed";
4     import Service from "../utils/structures/Service";
5    
6     export default class Starboard extends Service {
7     async handle(reaction: MessageReaction) {
8     if (this.client.config.get('starboard').enabled) {
9     let emoji = reaction.emoji.name;
10    
11     console.log(emoji);
12    
13     if (emoji === '⭐' && reaction.message.channel.id !== this.client.config.get('starboard').channel && reaction.count === this.client.config.get('starboard').reactions) {
14     try {
15     const channel = <TextChannel> await reaction.message.guild!.channels.fetch(this.client.config.get('starboard').channel);
16    
17     let props = {
18     embeds: reaction.message.embeds || []
19     };
20    
21     const msg = await channel.send({
22     embeds: [
23     ...props.embeds,
24     new MessageEmbed()
25     .setAuthor({
26     name: reaction.message.author!.tag,
27     iconURL: reaction.message.author!.displayAvatarURL(),
28     })
29     .setDescription(reaction.message.content!)
30     .addField('URL', `[Click here](${reaction.message.url})`)
31     .setTimestamp()
32     .setFooter({
33     text: reaction.message.id + ''
34     })
35     ],
36     files: reaction.message.attachments.map(a => {
37     return {
38     name: a.name,
39     attachment: a.proxyURL
40     } as MessageAttachment
41     })
42     });
43    
44     await msg.react('⭐');
45     }
46     catch (e) {
47     console.log(e);
48     }
49     }
50     }
51     }
52     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26