Always register a cooldown even when the limit has not been hit
This commit is contained in:
parent
2c37b3a64f
commit
f8cf11e7ff
1 changed files with 7 additions and 10 deletions
|
@ -13,7 +13,7 @@ function check(user, commandName, commands) {
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
if (ratelimit[userID][commandName]) {
|
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) {
|
if (date > ratelimit[userID][commandName].cooldown) {
|
||||||
ratelimit[userID][commandName].limit = 0;
|
ratelimit[userID][commandName].limit = 0;
|
||||||
ratelimit[userID][commandName].cooldown = undefined;
|
ratelimit[userID][commandName].cooldown = undefined;
|
||||||
|
@ -32,12 +32,9 @@ function check(user, commandName, commands) {
|
||||||
|
|
||||||
|
|
||||||
if (commands.ratelimit) {
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
Loading…
Reference in a new issue