Skip to content

Commit

Permalink
Merge pull request #194 from zusorio/update-discord-name-on-login
Browse files Browse the repository at this point in the history
Update discord name on login
  • Loading branch information
slmnio authored Aug 9, 2023
2 parents cfa8a55 + a4518e7 commit 4512fd6
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 4512fd6

Please sign in to comment.