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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26