I am currently trying to do a cooldown, the code is not mine, but would like to understand why I am getting this error and wonder how to fix it
const cooldowns = new Map();
if(cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection())
}
const current = Date.now()
const time_stamps = cooldowns.get(command.name)
const cooldown = (command.cooldown) * 1000;
if(time_stamps.has(message.author.id)) {
const expiration = time_stamps.get(message.author.id) + cooldown
if(current < expiration) {
const time = (expiration - current) / 1000;
return message.reply("message")
}
}
time_stamps.set(message.author.id, current);
setTimeout(() => time_stamps.delete(message.author.id), cooldown);
Error:
if(time_stamps.has(message.author.id)) {
^
TypeError: Cannot read properties of undefined (reading 'has')