From a48c4f9bea1b364744cf5ee701ac8b5164b0d8e7 Mon Sep 17 00:00:00 2001 From: Tarrgon <61888458+Tarrgon@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:22:45 -0500 Subject: [PATCH] Error on non-200 response --- src/utils/oauth2.ts | 6 ++++++ src/webserver/index.ts | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/oauth2.ts b/src/utils/oauth2.ts index 3368826..c2f0ede 100644 --- a/src/utils/oauth2.ts +++ b/src/utils/oauth2.ts @@ -103,6 +103,12 @@ export class DiscordOAuth2 { } }); + if (res.status < 200 || res.status >= 300) { + console.error(`Non 200 code while joining user: ${options.userId} to discord:`); + console.log(await res.text()); + return null; + } + return await res.json(); } diff --git a/src/webserver/index.ts b/src/webserver/index.ts index ac2f9fc..dcf6240 100644 --- a/src/webserver/index.ts +++ b/src/webserver/index.ts @@ -67,12 +67,16 @@ async function joinGuild(code: string, userId: string, username: string): Promis if (await checkAltsForFullBans([alts])) return JoinResponse.Banned; - await oauth.addMember({ + const response = await oauth.addMember({ accessToken: tokenResponse.access_token, guildId: config.DISCORD_GUILD_ID!, userId: user.id, nickname: username }); + + if (config.DEBUG) console.log(response); + + if (!response) return JoinResponse.Error; } catch (e: any) { if (e.code == 40007) return JoinResponse.Banned; else if (e.code == 20024) return JoinResponse.Underage;