Update gitignore
This commit is contained in:
commit
9e0ddb8182
32 changed files with 3863 additions and 0 deletions
18
src/cooldowns.js
Normal file
18
src/cooldowns.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const cooldowns = new Map();
|
||||
|
||||
function isOnCooldown(actionId, cooldownSeconds) {
|
||||
if (!cooldownSeconds) return false;
|
||||
const last = cooldowns.get(actionId);
|
||||
if (!last) return false;
|
||||
return (Date.now() - last) < cooldownSeconds * 1000;
|
||||
}
|
||||
|
||||
function setCooldown(actionId) {
|
||||
cooldowns.set(actionId, Date.now());
|
||||
}
|
||||
|
||||
function resetCooldown(actionId) {
|
||||
cooldowns.delete(actionId);
|
||||
}
|
||||
|
||||
module.exports = { isOnCooldown, setCooldown, resetCooldown };
|
||||
Loading…
Add table
Add a link
Reference in a new issue