Allow script to skip users

This commit is contained in:
Kalle
2023-03-26 22:40:58 +03:00
parent 782a0e6c6d
commit 935b5ff955

View File

@@ -17,9 +17,18 @@ const stm = sql.prepare(
/* sql */ `insert into "TournamentBadgeOwner" ("badgeId", "userId") values (@badgeId, (select "id" from "User" where "discordId" = @userId))`
);
const userStm = sql.prepare(
/* sql */ `select "id" from "User" where "discordId" = @discordId`
);
const users = discordIds.split(",");
for (const userId of users) {
const user = userStm.get({ discordId: userId });
if (!user) {
console.log(`User with discord id ${userId} not found`);
continue;
}
stm.run({ badgeId: Number(badgeId), userId });
}