testing in prod
This commit is contained in:
parent
1e1b78e24f
commit
91693ce2ae
|
@ -45,6 +45,8 @@ const awards = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let timeouts = {}
|
||||||
|
|
||||||
module.exports.run = () => {
|
module.exports.run = () => {
|
||||||
client.on('messageReactionAdd', async function(reaction, user) {
|
client.on('messageReactionAdd', async function(reaction, user) {
|
||||||
// Fetch reaction and user if they are partial
|
// Fetch reaction and user if they are partial
|
||||||
|
@ -70,15 +72,21 @@ module.exports.run = () => {
|
||||||
return;
|
return;
|
||||||
} else if (awards[reaction.emoji.id]) {
|
} else if (awards[reaction.emoji.id]) {
|
||||||
let award = 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) {
|
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);
|
reaction.users.remove(user.id);
|
||||||
|
timeouts[user.id] = Date.now() + 5000;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message.author.id == user.id) {
|
if (message.author.id == user.id) {
|
||||||
//reaction.remove();
|
|
||||||
reaction.users.remove(user.id);
|
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(user.id, (coins.get(user.id) - award.cost));
|
||||||
coins.set(message.author.id, (coins.get(message.author.id) + award.give));
|
coins.set(message.author.id, (coins.get(message.author.id) + award.give));
|
||||||
|
|
Loading…
Reference in a new issue