Skip to content

Commit 27fb2ac

Browse files
committed
Add support for user and guild installations for application.commands scope
1 parent f68155e commit 27fb2ac

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

discordoauth2/async_oauth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def generate_uri(
467467
scope: Union[str, list[str]],
468468
state: Optional[str] = None,
469469
skip_prompt: Optional[bool] = False,
470+
integration_type: Optional[Literal["guild", "user"]] = "user",
470471
response_type: Optional[Literal["code", "token"]] = "code",
471472
guild_id: Optional[Union[int, str]] = None,
472473
disable_guild_select: Optional[bool] = None,
@@ -493,4 +494,6 @@ def generate_uri(
493494
"disable_guild_select": disable_guild_select,
494495
"permissions": permissions,
495496
}
497+
if "application.commands" in scope:
498+
params["integration_type"] = 0 if integration_type == "guild" else 1
496499
return f"https://discord.com/oauth2/authorize?{parse.urlencode({key: value for key, value in params.items() if value is not None})}"

discordoauth2/sync_oauth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def generate_uri(
438438
scope: Union[str, list[str]],
439439
state: Optional[str] = None,
440440
skip_prompt: Optional[bool] = False,
441+
integration_type: Optional[Literal["guild", "user"]] = "user",
441442
response_type: Optional[Literal["code", "token"]] = "code",
442443
guild_id: Optional[Union[int, str]] = None,
443444
disable_guild_select: Optional[bool] = None,
@@ -464,4 +465,6 @@ def generate_uri(
464465
"disable_guild_select": disable_guild_select,
465466
"permissions": permissions,
466467
}
468+
if "application.commands" in scope:
469+
params["integration_type"] = 0 if integration_type == "guild" else 1
467470
return f"https://discord.com/oauth2/authorize?{parse.urlencode({key: value for key, value in params.items() if value is not None})}"

0 commit comments

Comments
 (0)