So what I'm trying to do is create a "cooldown" like system for my discord bot, I've tried using a database method, here which doesn't work for me.
I'm using the discord.js package.
Here is my code:
if (msg.content.startsWith("!point")) {
var usr = msg.content.split(" ").slice(1).join(" ");
if (!usr) {
bot.sendMessage(msg, "```Error: 1\n Reason: Please state a name.```");
return;
}
if (usr == msg.author.username) {
bot.sendMessage(msg, "```Error: 3\n Reason: You're unable to point yourself.```");
return;
}
if (!db["users"][usr]) {
db["users"][usr] = 0;
}
console.log(usr + " has " + db["users"][usr]);
db["users"][usr] += 1;
console.log(usr + " now has " + db["users"][usr]);
fs.writeFileSync('database.json', JSON.stringify(db));
bot.sendMessage(msg, usr + " has received 1 point");
}