Skip to content

Commit

Permalink
fix(logs): don't set to 2 when the count is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Oct 12, 2021
1 parent d3078db commit 76cb992
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions detector/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module.exports = async (client, guildId, userId) => {
// Update user count
const userData = client.db.prepare('SELECT count FROM users WHERE id = ?').get(userId);
const userStatement = userData ? 'UPDATE users SET count = @count WHERE id = @id' : 'INSERT INTO users (id, count) VALUES (@id, @count)';
client.db.prepare(userStatement).run({ id: userId, count: (userData?.count ?? 1) + 1 });
client.db.prepare(userStatement).run({ id: userId, count: (userData?.count ?? 0) + 1 });

// Update guild count
const guildData = client.db.prepare('SELECT count FROM guilds WHERE id = ?').get(guildId);
const guildStatement = guildData ? 'UPDATE guilds SET count = @count WHERE id = @id' : 'INSERT INTO guilds (id, count) VALUES (@id, @count)';
client.db.prepare(guildStatement).run({ id: guildId, count: (guildData?.count ?? 1) + 1 });
client.db.prepare(guildStatement).run({ id: guildId, count: (guildData?.count ?? 0) + 1 });
};

0 comments on commit 76cb992

Please sign in to comment.