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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26