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

This commit is contained in:
Supositware 2022-12-20 19:53:41 +01:00
parent 2c37b3a64f
commit f8cf11e7ff

View file

@ -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] ? ratelimit[userID][commandName].limit + 1 : 1, cooldown: date };
}
ratelimit[userID][commandName] = { limit: ratelimit[userID][commandName].limit, cooldown: date };
}
}
return false;
}