Always register a cooldown even when the limit has not been hit

pull/1/head
Supositware 1 year ago
parent 2c37b3a64f
commit f8cf11e7ff

@ -13,7 +13,7 @@ function check(user, commandName, commands) {
const date = new Date();
if (ratelimit[userID][commandName]) {
if (ratelimit[userID][commandName].cooldown) {
if (ratelimit[userID][commandName].cooldown && ratelimit[userID][commandName].limit === commands.ratelimit) {
if (date > ratelimit[userID][commandName].cooldown) {
ratelimit[userID][commandName].limit = 0;
ratelimit[userID][commandName].cooldown = undefined;
@ -32,12 +32,9 @@ function check(user, commandName, commands) {
if (commands.ratelimit) {
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName] ? ratelimit[userID][commandName].limit + 1 : 1 };
if (commands.ratelimit === ratelimit[userID][commandName].limit) {
date.setSeconds(date.getSeconds() + commands.cooldown);
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName].limit, cooldown: date };
}
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName] ? ratelimit[userID][commandName].limit + 1 : 1, cooldown: date };
}
return false;
}
Loading…
Cancel
Save