testing in prod

This commit is contained in:
Jan 2020-12-23 13:58:04 +01:00
parent 1e1b78e24f
commit 91693ce2ae

View file

@ -45,6 +45,8 @@ const awards = {
}
}
let timeouts = {}
module.exports.run = () => {
client.on('messageReactionAdd', async function(reaction, user) {
// Fetch reaction and user if they are partial
@ -70,15 +72,21 @@ module.exports.run = () => {
return;
} else if (awards[reaction.emoji.id]) {
let award = awards[reaction.emoji.id];
let perms = message.channel.permissionsFor(user.id);
if (!perms.has('SEND_MESSAGES') || !perms.has('ADD_REACTIONS')) return reaction.users.remove(user.id);
if (coins.get(user.id) < award.cost) {
message.channel.send(`${user}, you don't have sufficient coins to use this award.`);
if (timeouts[user.id] < Date.now()) message.channel.send(`${user}, you don't have sufficient coins to use this award.`);
reaction.users.remove(user.id);
timeouts[user.id] = Date.now() + 5000;
return;
}
if (message.author.id == user.id) {
//reaction.remove();
reaction.users.remove(user.id);
return message.channel.send(`${user}, why would you give an award to yourself? smh my head`);
if (timeouts[user.id] < Date.now()) message.channel.send(`${user}, why would you give an award to yourself? smh my head`);
timeouts[user.id] = Date.now() + 5000;
return;
}
coins.set(user.id, (coins.get(user.id) - award.cost));
coins.set(message.author.id, (coins.get(message.author.id) + award.give));