raw event

This commit is contained in:
Daniel Odendahl Jr
2017-12-12 14:48:16 +00:00
parent 7e0b93499a
commit 735548d5dc
3 changed files with 19 additions and 9 deletions
+18
View File
@@ -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 => {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "56.6.0",
"version": "56.6.1",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {
-8
View File
@@ -61,14 +61,6 @@ class Util {
return arr;
}
static promisifyAll(obj, suffix = 'Async') {
for (const key of Object.keys(obj)) {
if (typeof obj[key] !== 'function') continue;
obj[`${key}${suffix}`] = promisify(obj[key]);
}
return obj;
}
static cleanXML(text) {
return text
.replace(/<br \/>/g, '')