Skip to content

Commit

Permalink
Update Discord Tags on slmngg login
Browse files Browse the repository at this point in the history
Co-authored-by: MrLotU <[email protected]>
  • Loading branch information
zusorio and MrLotU committed Jul 9, 2023
1 parent e45c53e commit 14e58f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/src/discord/auth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const bodyParser = require("body-parser");
const fetch = require("node-fetch");
const { updateRecord } = require("../action-utils/action-utils");

function discordEnvSet() {
return ["DISCORD_CLIENT_ID", "DISCORD_CLIENT_SECRET"].every(key => !!process.env[key])
Expand Down Expand Up @@ -146,6 +147,11 @@ module.exports = ({ app, router, cors, Cache, io }) => {

let airtable = await getAirtablePlayer(discord);

if (![discord.username, `${discord.username}#${discord.discriminator}`].includes(airtable.discord_tag)) {
const updatedUsername = discord.discriminator === "0" ? discord.username : `${discord.username}#${discord.discriminator}`;
await updateRecord(Cache, "Players", airtable, { "Discord Tag": updatedUsername });
}

return { discord, airtable };
}

Expand Down

0 comments on commit 14e58f2

Please sign in to comment.