/[sudobot]/trunk/src/services/Starboard.ts
ViewVC logotype

Diff of /trunk/src/services/Starboard.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/Starboard.js revision 33 by rakin, Mon Jul 29 17:28:17 2024 UTC trunk/src/services/Starboard.ts revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  const MessageEmbed = require("../src/MessageEmbed");  import { MessageAttachment, MessageReaction, TextChannel } from "discord.js";
2    import MessageEmbed from "../client/MessageEmbed";
3    import Service from "../utils/structures/Service";
4    
5  module.exports = class Starboard {  export default class Starboard extends Service {
6      async handle(reaction, user) {      async handle(reaction: MessageReaction) {
7          if (app.config.get('starboard').enabled) {          if (this.client.config.get('starboard').enabled) {
8              let emoji;              let emoji = reaction.emoji.name;
   
             if (typeof reaction._emoji !== 'undefined')  
                 emoji = reaction._emoji.name;  
             else  
                 emoji = reaction.anme;  
9                            
10              console.log(reaction, emoji);              console.log(emoji);
11    
12              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) {
13                  try {                  try {
14                      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);
15    
16                      let props = {                      let props = {
17                          embeds: reaction.message.embeds || []                          embeds: reaction.message.embeds || []
18                      }                      };
19            
20                      const msg = await channel.send({                      const msg = await channel.send({
21                          embeds: [                          embeds: [
22                              ...props.embeds,                              ...props.embeds,
23                              new MessageEmbed()                              new MessageEmbed()
24                              .setAuthor({                              .setAuthor({
25                                  name: reaction.message.author.tag,                                  name: reaction.message.author!.tag,
26                                  iconURL: reaction.message.author.displayAvatarURL(),                                  iconURL: reaction.message.author!.displayAvatarURL(),
27                              })                              })
28                              .setDescription(reaction.message.content)                              .setDescription(reaction.message.content!)
29                              .addField('URL', `[Click here](${reaction.message.url})`)                              .addField('URL', `[Click here](${reaction.message.url})`)
30                              .setTimestamp()                              .setTimestamp()
31                              .setFooter({                              .setFooter({
# Line 39  module.exports = class Starboard { Line 36  module.exports = class Starboard {
36                              return {                              return {
37                                  name: a.name,                                  name: a.name,
38                                  attachment: a.proxyURL                                  attachment: a.proxyURL
39                              }                              } as MessageAttachment
40                          })                          })
41                      });                      });
42            

Legend:
Removed from v.33  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26