thaldrin/events/messageReactionAdd.js

36 lines
1.2 KiB
JavaScript

const p = require('phin').defaults({
method: 'POST',
parse: 'json'
});
module.exports = {
name: 'messageReactionAdd',
run: async (client, reaction, user) => {
if (user.bot) return;
if (!client.config.developers.find(id => id == user.id)) return;
if (reaction.emoji.name == '📥') {
try {
if (!client.cache.lastEval) {
await reaction.message.edit(`\`Unable to upload uncached eval results\``);
await reaction.message.reactions.removeAll();
} else {
const { body } = await p({
url: `https://hasteb.in/documents`,
data: `${client.cache.lastEval || `Last eval resuts weren't cached`}`
});
await reaction.message.edit(`<https://hasteb.in/${body.key}>`);
await reaction.message.reactions.removeAll();
}
} catch(err) {}
}
if (reaction.emoji.name == '🗑') {
try {
await reaction.message.delete();
} catch(err) {}
}
}
}