Skip to content

Commit

Permalink
Persist removed extraneous game options from guildpreference (#1859)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Feb 4, 2024
1 parent 75f101c commit da24436
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/structures/guild_preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export default class GuildPreference {
}

// extraneous keys
// TODO: this doesn't actually remove the entries in the database
for (const option in validatedGameOptions) {
if (!(option in GuildPreference.DEFAULT_OPTIONS)) {
extraneousKeysRemoved++;
Expand Down Expand Up @@ -974,13 +973,15 @@ export default class GuildPreference {
}

await dbContext.kmq.transaction().execute(async (trx) => {
await trx
.deleteFrom("game_options")
.where("guild_id", "=", this.guildID)
.where("client_id", "=", process.env.BOT_CLIENT_ID as string)
.execute();

await Promise.all(
updatedOptions.map((x) =>
trx
.insertInto("game_options")
.values(x)
.onDuplicateKeyUpdate(x)
.execute(),
trx.insertInto("game_options").values(x).execute(),
),
);
});
Expand Down

0 comments on commit da24436

Please sign in to comment.