Error on non-200 response
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user