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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 393 - (hide annotations)
Mon Jul 29 17:29:59 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 2880 byte(s)
style: add license comments (#77)

* style: add license commits

* fix: shebang errors
1 rakin 393 /**
2     * This file is part of SudoBot.
3     *
4     * Copyright (C) 2021-2022 OSN Inc.
5     *
6     * SudoBot is free software; you can redistribute it and/or modify it
7     * under the terms of the GNU Affero General Public License as published by
8     * the Free Software Foundation, either version 3 of the License, or
9     * (at your option) any later version.
10     *
11     * SudoBot is distributed in the hope that it will be useful, but
12     * WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU Affero General Public License for more details.
15     *
16     * You should have received a copy of the GNU Affero General Public License
17     * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18     */
19    
20 rakin 344 import { MessageAttachment, MessageReaction, TextChannel } from "discord.js";
21 rakin 51 import MessageEmbed from "../client/MessageEmbed";
22 rakin 226 import Service from "../utils/structures/Service";
23 rakin 33
24 rakin 226 export default class Starboard extends Service {
25 rakin 51 async handle(reaction: MessageReaction) {
26     if (this.client.config.get('starboard').enabled) {
27     let emoji = reaction.emoji.name;
28 rakin 33
29 rakin 51 console.log(emoji);
30 rakin 33
31 rakin 51 if (emoji === '⭐' && reaction.message.channel.id !== this.client.config.get('starboard').channel && reaction.count === this.client.config.get('starboard').reactions) {
32 rakin 33 try {
33 rakin 51 const channel = <TextChannel> await reaction.message.guild!.channels.fetch(this.client.config.get('starboard').channel);
34 rakin 33
35     let props = {
36     embeds: reaction.message.embeds || []
37 rakin 51 };
38 rakin 33
39     const msg = await channel.send({
40     embeds: [
41     ...props.embeds,
42     new MessageEmbed()
43     .setAuthor({
44 rakin 51 name: reaction.message.author!.tag,
45     iconURL: reaction.message.author!.displayAvatarURL(),
46 rakin 33 })
47 rakin 51 .setDescription(reaction.message.content!)
48 rakin 33 .addField('URL', `[Click here](${reaction.message.url})`)
49     .setTimestamp()
50     .setFooter({
51     text: reaction.message.id + ''
52     })
53     ],
54     files: reaction.message.attachments.map(a => {
55     return {
56     name: a.name,
57     attachment: a.proxyURL
58 rakin 51 } as MessageAttachment
59 rakin 33 })
60     });
61    
62     await msg.react('⭐');
63     }
64     catch (e) {
65     console.log(e);
66     }
67     }
68     }
69     }
70     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26