Skip to content

Commit

Permalink
Merge pull request #354 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Update DiscordController.php
  • Loading branch information
JoshuaMicallefYBSU authored Oct 17, 2024
2 parents 311d80d + 56b0b9e commit f548a65
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/Http/Controllers/Community/DiscordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function joinCallbackDiscord(Request $request)
//Get access token using returned code
$http = new Client();

try {
// try {
$response = $http->post('https://discord.com/api/v10/oauth2/token', [
'form_params' => [
'client_id' => env('DISCORD_CLIENT_ID'),
Expand All @@ -255,14 +255,15 @@ public function joinCallbackDiscord(Request $request)
],
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded']
]);
} catch (ClientException $e) {
return redirect()->route('my.index')->with('error-modal', $e->getMessage().'... Unable to get Discord Authorisation Code');
}
// } catch (ClientException $e) {
// return redirect()->route('my.index')->with('error-modal', $e->getMessage().'... Unable to get Discord Authorisation Code');
// }

$access_token = json_decode($response->getBody(), true)['access_token'];


//Make em join Discord
try {
// try {
$response = (new Client())
->put(
'https://discord.com/api/v10/guilds/'.env('DISCORD_GUILD_ID').'/members/'.$user->discord_user_id,
Expand All @@ -277,9 +278,9 @@ public function joinCallbackDiscord(Request $request)
]
]
);
} catch (ClientException $e) {
return redirect()->route('my.index')->with('error-modal', $e->getMessage().'.... Unable to update User Details.');
}
// } catch (ClientException $e) {
// return redirect()->route('my.index')->with('error-modal', $e->getMessage().'.... Unable to update User Details.');
// }


//DM them
Expand Down

0 comments on commit f548a65

Please sign in to comment.