Skip to content

Commit 5de2f61

Browse files
committedMar 31, 2025
Fix discord sync
1 parent 3a9f321 commit 5de2f61

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

‎app/Console/Commands/Users/RegenerateDiscordToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function handle()
4646
{
4747
// $userID = $this->argument('user');
4848

49-
$tokens = UserApp::select(['id', 'user_id', 'access_token', 'refresh_token', 'expires_at', 'updated_at'])
49+
$tokens = UserApp::select(['id', 'user_id', 'access_token', 'refresh_token', 'expires_at', 'updated_at', 'settings'])
5050
->with('user')
5151
->where('app', '=', 'discord')
5252
->where('expires_at', '<=', Carbon::now()->toDateString())

‎app/Services/DiscordService.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class DiscordService
2020
/** @var UserApp|null */
2121
protected $app;
2222

23-
protected string $url = 'https://discord.com/api/v6/';
23+
protected string $url = 'https://discord.com/api/v10/';
2424

25-
protected $me = false;
25+
protected $me;
2626

2727
protected array $logs = [];
2828

@@ -81,7 +81,7 @@ public function addServer(): self
8181
public function me()
8282
{
8383
// Cache the response during a single process
84-
if ($this->me !== false) {
84+
if (isset($this->me)) {
8585
return $this->me;
8686
}
8787

@@ -119,7 +119,7 @@ protected function saveUserApp($data): self
119119

120120
// Get me for data
121121
$me = $this->me();
122-
$this->app->settings = ['username' => $me->username, 'discriminator' => $me->discriminator];
122+
$this->app->settings = ['username' => $me->username];
123123
$this->app->save();
124124

125125
return $this;
@@ -136,7 +136,6 @@ public function refresh()
136136
if (! $this->app->expires_at->isPast()) {
137137
return $this;
138138
}
139-
140139
$body = [
141140
'client_id' => config('discord.client_id'),
142141
'client_secret' => config('discord.client_secret'),
@@ -151,6 +150,9 @@ public function refresh()
151150
$log = 'Renewed user #' . $this->user->id . ' Discord auth token.';
152151
$this->logs[] = $log;
153152

153+
// Clear the cached Discord user
154+
unset($this->me);
155+
154156
return $this;
155157
}
156158

0 commit comments

Comments
 (0)
Failed to load comments.