Skip to content

Commit 2601521

Browse files
authored
Merge pull request #734 from Exairnous/use-discord-display-names
Check for the global name if the per-server nickname isn't present
2 parents 21ae264 + 89058c3 commit 2601521

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/ret/discord_client.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,20 @@ defmodule Ret.DiscordClient do
7676
{status, result} when status in [:commit, :ok] -> "#{result["nick"]}"
7777
end
7878

79-
if nickname == "" do
79+
nickname = if !nickname or nickname == "" do
80+
case Cachex.fetch(:discord_api, "/users/#{provider_account_id}") do
81+
{status, result} when status in [:commit, :ok] -> "#{result["global_name"]}"
82+
end
83+
else
84+
nickname
85+
end
86+
87+
nickname = if !nickname or nickname == "" do
8088
case Cachex.fetch(:discord_api, "/users/#{provider_account_id}") do
8189
{status, result} when status in [:commit, :ok] -> "#{result["username"]}"
8290
end
83-
else
84-
nickname
91+
else
92+
nickname
8593
end
8694
end
8795

0 commit comments

Comments
 (0)