diff options
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/database.ts b/src/database.ts index 26fa76f..c2fa026 100644 --- a/src/database.ts +++ b/src/database.ts @@ -93,6 +93,7 @@ interface SessionSchema { export interface AccountCustomization { backgroundUrl?: string pack?: string + blurBackground?: boolean emoji?: string } @@ -817,6 +818,16 @@ export async function fetchAccountFromDiscord(discordId: string): Promise<WithId } export async function updateAccount(discordId: string, schema: AccountSchema) { + if (schema.minecraftUuid) { + const existingAccount = await accountsCollection?.findOne({ minecraftUuid: schema.minecraftUuid }) + // if the discord ids don't match, change the discord id of the existing account + if (existingAccount && existingAccount.discordId !== discordId) { + await accountsCollection?.updateOne( + { minecraftUuid: schema.minecraftUuid }, + { '$set': { discordId } } + ) + } + } await accountsCollection?.updateOne({ discordId }, { $set: schema }, { upsert: true }) |