/[sudobot]/trunk/src/Starboard.js
ViewVC logotype

Contents of /trunk/src/Starboard.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (show annotations)
Mon Jul 29 17:28:17 2024 UTC (8 months ago) by rakin
File MIME type: text/javascript
File size: 2078 byte(s)
Added starboard feature
1 const MessageEmbed = require("../src/MessageEmbed");
2
3 module.exports = class Starboard {
4 async handle(reaction, user) {
5 if (app.config.get('starboard').enabled) {
6 let emoji;
7
8 if (typeof reaction._emoji !== 'undefined')
9 emoji = reaction._emoji.name;
10 else
11 emoji = reaction.anme;
12
13 console.log(reaction, emoji);
14
15 if (emoji === '⭐' && reaction.message.channel.id !== app.config.get('starboard').channel && reaction.count === app.config.get('starboard').messages) {
16 try {
17 const channel = await reaction.message.guild.channels.fetch(app.config.get('starboard').channel);
18
19 let props = {
20 embeds: reaction.message.embeds || []
21 }
22
23 const msg = await channel.send({
24 embeds: [
25 ...props.embeds,
26 new MessageEmbed()
27 .setAuthor({
28 name: reaction.message.author.tag,
29 iconURL: reaction.message.author.displayAvatarURL(),
30 })
31 .setDescription(reaction.message.content)
32 .addField('URL', `[Click here](${reaction.message.url})`)
33 .setTimestamp()
34 .setFooter({
35 text: reaction.message.id + ''
36 })
37 ],
38 files: reaction.message.attachments.map(a => {
39 return {
40 name: a.name,
41 attachment: a.proxyURL
42 }
43 })
44 });
45
46 await msg.react('⭐');
47 }
48 catch (e) {
49 console.log(e);
50 }
51 }
52 }
53 }
54 };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26