Fixed database thing

This commit is contained in:
TheEssem 2021-03-05 15:20:15 -06:00
parent f0c685d8c4
commit f6bec828d7

View file

@ -60,6 +60,7 @@ exports.getCounts = async () => {
exports.addCount = async (command) => {
const count = await connection.query("SELECT * FROM counts WHERE command = $1", [command]);
if (!count.rows[0]) await connection.query("INSERT INTO counts (command, count) VALUES ($1, $2)", [command, 0]);
await connection.query("UPDATE counts SET count = $1 WHERE command = $2", [count.rows[0].count ? count.rows[0].count + 1 : 1, command]);
};