/[sudobot]/trunk/src/events/raw/RawEvent.ts
ViewVC logotype

Annotation of /trunk/src/events/raw/RawEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (hide annotations)
Mon Jul 29 17:29:40 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1174 byte(s)
chore: eslint autofix
1 rakin 51 import BaseEvent from '../../utils/structures/BaseEvent';
2     import DiscordClient from '../../client/Client';
3     import { TextChannel } from 'discord.js';
4    
5     export default class RawEvent extends BaseEvent {
6     events = {
7     MESSAGE_REACTION_ADD: 'messageReactionAdd',
8     };
9    
10     constructor() {
11     super('raw');
12     }
13    
14     async run(client: DiscordClient, event: { d: any, t: keyof RawEvent['events'] }) {
15     if (!this.events.hasOwnProperty(event.t))
16     return;
17    
18     const { d: data } = event;
19     // const user = client.users.cache.find(i => i.id === data.user_id);
20     const channel = <TextChannel> client.channels.cache.find(i => i.id === data.channel_id);
21    
22     if (channel) {
23     if (channel.messages.cache.has(data.message_id))
24     return;
25    
26     const message = await channel.messages.fetch(data.message_id);
27    
28     const emojiKey = (data.emoji.id) ? `${data.emoji.name}:${data.emoji.id}` : data.emoji.name;
29     const reaction = message.reactions.cache.get(emojiKey);
30    
31     client.emit(this.events[event.t], reaction, message);
32     }
33     }
34     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26