From dac284a01e7dbbd79a89b75c0fee0454465bcbdf Mon Sep 17 00:00:00 2001 From: Fleny Date: Fri, 24 Jul 2026 20:52:16 +0200 Subject: [PATCH] fix: make scope optional in createOAuth2Link (#5182) --- packages/utils/src/oauth2.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/utils/src/oauth2.ts b/packages/utils/src/oauth2.ts index 9f6c166df..4e2de2962 100644 --- a/packages/utils/src/oauth2.ts +++ b/packages/utils/src/oauth2.ts @@ -3,10 +3,9 @@ import { encodeBase64Url } from './base64.js'; import { calculateBits } from './permissions.js'; export function createOAuth2Link(options: CreateOAuth2LinkOptions): string { - const joinedScopeString = options.scope.join('%20'); - - let url = `https://discord.com/oauth2/authorize?client_id=${options.clientId}&scope=${joinedScopeString}`; + let url = `https://discord.com/oauth2/authorize?client_id=${options.clientId}`; + if (options.scope) url += `&scope=${options.scope.join('%20')}`; if (options.responseType) url += `&response_type=${options.responseType}`; if (options.state) url += `&state=${encodeURIComponent(options.state)}`; if (options.redirectUri) url += `&redirect_uri=${encodeURIComponent(options.redirectUri)}`; @@ -66,7 +65,7 @@ export interface CreateOAuth2LinkOptions { /** The id of the application */ clientId: BigString; /** The scopes for the application */ - scope: OAuth2Scope[]; + scope?: OAuth2Scope[]; /** * The optional state for security *