mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Add disable_guild_select to utils.oauth_url()
This commit is contained in:
parent
d30fea5b0d
commit
dbb135b81a
@ -251,18 +251,20 @@ def deprecated(instead: Optional[str] = None) -> Callable[[Callable[..., T]], Ca
|
|||||||
|
|
||||||
|
|
||||||
def oauth_url(
|
def oauth_url(
|
||||||
client_id: str,
|
client_id: Union[int, str],
|
||||||
permissions: Optional[Permissions] = None,
|
*,
|
||||||
guild: Optional[Snowflake] = None,
|
permissions: Permissions = MISSING,
|
||||||
redirect_uri: Optional[str] = None,
|
guild: Snowflake = MISSING,
|
||||||
scopes: Optional[Iterable[str]] = None,
|
redirect_uri: str = MISSING,
|
||||||
|
scopes: Iterable[str] = MISSING,
|
||||||
|
disable_guild_select: bool = False,
|
||||||
):
|
):
|
||||||
"""A helper function that returns the OAuth2 URL for inviting the bot
|
"""A helper function that returns the OAuth2 URL for inviting the bot
|
||||||
into guilds.
|
into guilds.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
client_id: :class:`str`
|
client_id: Union[:class:`int`, :class:`str`]
|
||||||
The client ID for your bot.
|
The client ID for your bot.
|
||||||
permissions: :class:`~discord.Permissions`
|
permissions: :class:`~discord.Permissions`
|
||||||
The permissions you're requesting. If not given then you won't be requesting any
|
The permissions you're requesting. If not given then you won't be requesting any
|
||||||
@ -275,6 +277,10 @@ def oauth_url(
|
|||||||
An optional valid list of scopes. Defaults to ``('bot',)``.
|
An optional valid list of scopes. Defaults to ``('bot',)``.
|
||||||
|
|
||||||
.. versionadded:: 1.7
|
.. versionadded:: 1.7
|
||||||
|
disable_guild_select: :class:`bool`
|
||||||
|
Whether to disallow the user from changing the guild dropdown.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
--------
|
--------
|
||||||
@ -282,15 +288,17 @@ def oauth_url(
|
|||||||
The OAuth2 URL for inviting the bot into guilds.
|
The OAuth2 URL for inviting the bot into guilds.
|
||||||
"""
|
"""
|
||||||
url = f'https://discord.com/oauth2/authorize?client_id={client_id}'
|
url = f'https://discord.com/oauth2/authorize?client_id={client_id}'
|
||||||
url = url + '&scope=' + '+'.join(scopes or ('bot',))
|
url += '&scope=' + '+'.join(scopes or ('bot',))
|
||||||
if permissions is not None:
|
if permissions is not MISSING:
|
||||||
url = url + '&permissions=' + str(permissions.value)
|
url += f'&permissions={permissions.value}'
|
||||||
if guild is not None:
|
if guild is not MISSING:
|
||||||
url = url + "&guild_id=" + str(guild.id)
|
url += f'&guild_id={guild.id}'
|
||||||
if redirect_uri is not None:
|
if redirect_uri is not MISSING:
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
url = url + "&response_type=code&" + urlencode({'redirect_uri': redirect_uri})
|
url += '&response_type=code&' + urlencode({'redirect_uri': redirect_uri})
|
||||||
|
if disable_guild_select:
|
||||||
|
url += '&disable_guild_select=true'
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user