mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 14:55:40 +02:00
raw event
This commit is contained in:
+18
@@ -106,6 +106,24 @@ client.on('messageReactionRemove', async reaction => {
|
||||
}
|
||||
});
|
||||
|
||||
client.on('raw', async event => {
|
||||
const data = event.d;
|
||||
if (event.t === 'MESSAGE_REACTION_ADD') {
|
||||
const channel = client.channels.get(data.channel_id);
|
||||
if (!data.emoji.id || channel.messages.has(data.message_id)) return;
|
||||
const user = client.users.get(data.user_id);
|
||||
const message = await channel.messages.fetch(data.message_id);
|
||||
const reaction = message.reactions.get(data.emoji.id);
|
||||
client.emit('messageReactionAdd', reaction, user);
|
||||
} else if (event.t === 'MESSAGE_REACTION_REMOVE') {
|
||||
const channel = client.channels.get(data.channel_id);
|
||||
if (!data.emoji.id || channel.messages.has(data.message_id)) return;
|
||||
const message = await channel.messages.fetch(data.message_id);
|
||||
const reaction = message.reactions.get(data.emoji.id);
|
||||
client.emit('messageReactionRemove', reaction);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(XIAO_TOKEN);
|
||||
|
||||
process.on('unhandledRejection', err => {
|
||||
|
||||
Reference in New Issue
Block a user