fix: make scope optional in createOAuth2Link (#5182)

This commit is contained in:
Fleny
2026-07-25 00:22:16 +05:30
committed by GitHub
parent 8ab0c293af
commit dac284a01e
+3 -4
View File
@@ -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
*