From e1313998a1fe45a5f7e4353a4d20e86995ebf606 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:49:21 +1000 Subject: [PATCH 1/2] Fix DiscordJoin issue --- .../Community/DiscordController.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Community/DiscordController.php b/app/Http/Controllers/Community/DiscordController.php index 3880da57..4677fc86 100644 --- a/app/Http/Controllers/Community/DiscordController.php +++ b/app/Http/Controllers/Community/DiscordController.php @@ -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'), @@ -255,15 +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()); + } $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, @@ -278,13 +278,13 @@ 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()); + } //DM them - $user->notify(new DiscordWelcome()); + // $user->notify(new DiscordWelcome()); --- Presently DMs do not work... $user->member_of_czqo = true; $user->save(); From cbb0cd2345ff7e469a0d4507052479c93f690c34 Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:59:24 +1000 Subject: [PATCH 2/2] Update DiscordController.php --- app/Http/Controllers/Community/DiscordController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/Community/DiscordController.php b/app/Http/Controllers/Community/DiscordController.php index 4677fc86..2a60de47 100644 --- a/app/Http/Controllers/Community/DiscordController.php +++ b/app/Http/Controllers/Community/DiscordController.php @@ -320,6 +320,7 @@ public function unlinkDiscord() $user->discord_user_id = null; $user->member_of_czqo = false; $user->discord_avatar = null; + $user->discord_username = null; //If they have a Discord avatar, remove it if ($user->avatar_mode == 2) {