thaldrin/DiscordEvents/EvalReaction.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2019-10-09 16:19:30 +00:00
const p = require('phin').defaults({
2019-11-10 08:42:09 +00:00
method: 'POST',
parse: 'json'
2019-10-09 16:19:30 +00:00
});
2019-11-10 08:42:09 +00:00
const hastebin = require('hastebin-gen');
2019-10-09 16:19:30 +00:00
module.exports = {
2019-11-10 08:42:09 +00:00
name: 'messageReactionAdd',
run: async (client, reaction, user) => {
if (user.bot) return;
if (user.id !== '318044130796109825') return;
if (reaction.emoji.name == '📥') {
let haste;
try {
if (!client.lastEval) {
await reaction.message.edit(`\`Unable to upload uncached eval results\``);
await reaction.message.reactions.removeAll();
} else {
2019-12-20 22:29:33 +00:00
hastebin(`${client.lastEval || `Last eval resuts weren't cached`}`, {
2019-12-21 10:13:41 +00:00
url: 'http://hasteb.in/documents',
2019-12-20 22:29:33 +00:00
extension: 'js'
})
2019-11-10 08:42:09 +00:00
.then(async (h) => {
await reaction.message.edit(`<${h}>`);
await reaction.message.reactions.removeAll();
})
.catch((error) => {
// Handle error
console.error(error);
});
}
} catch (err) {
console.error(err);
}
}
2019-10-09 16:19:30 +00:00
2019-11-10 08:42:09 +00:00
if (reaction.emoji.name == '🗑') {
try {
await reaction.message.delete();
} catch (err) {}
}
}
};