From 800d479863af3e0548bb5c77d229aa1b9a2c143f Mon Sep 17 00:00:00 2001 From: Simponic Date: Tue, 31 Jan 2023 20:59:01 -0700 Subject: [PATCH] Add discriminator to username when oauth'd --- lib/chessh/web/web.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/chessh/web/web.ex b/lib/chessh/web/web.ex index aac57fc..2b465b2 100644 --- a/lib/chessh/web/web.ex +++ b/lib/chessh/web/web.ex @@ -267,11 +267,12 @@ defmodule Chessh.Web.Endpoint do [] ) do {:ok, {{_, 200, 'OK'}, _, user_details}} -> - %{"username" => username, "id" => discord_id} = + %{"username" => username, "discriminator" => discriminator, "id" => discord_id} = Jason.decode!(String.Chars.to_string(user_details)) %Player{id: id} = - Repo.insert!(%Player{discord_id: discord_id, username: username}, + Repo.insert!( + %Player{discord_id: discord_id, username: username <> "#" <> discriminator}, on_conflict: [set: [discord_id: discord_id]], conflict_target: :discord_id )