Add optional redirect_uri parameter to utils.oauth_url
This commit is contained in:
parent
8d7dd79673
commit
bd5effeb68
@ -75,7 +75,7 @@ def parse_time(timestamp):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def oauth_url(client_id, permissions=None, server=None):
|
def oauth_url(client_id, permissions=None, server=None, redirect_uri=None):
|
||||||
"""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 servers.
|
into servers.
|
||||||
|
|
||||||
@ -88,12 +88,17 @@ def oauth_url(client_id, permissions=None, server=None):
|
|||||||
permissions.
|
permissions.
|
||||||
server : :class:`Server`
|
server : :class:`Server`
|
||||||
The server to pre-select in the authorization screen, if available.
|
The server to pre-select in the authorization screen, if available.
|
||||||
|
redirect_uri : str
|
||||||
|
An optional valid redirect URI.
|
||||||
"""
|
"""
|
||||||
url = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot'.format(client_id)
|
url = 'https://discordapp.com/oauth2/authorize?client_id={}&scope=bot'.format(client_id)
|
||||||
if permissions is not None:
|
if permissions is not None:
|
||||||
url = url + '&permissions=' + str(permissions.value)
|
url = url + '&permissions=' + str(permissions.value)
|
||||||
if server is not None:
|
if server is not None:
|
||||||
url = url + "&guild_id=" + server.id
|
url = url + "&guild_id=" + server.id
|
||||||
|
if redirect_uri is not None:
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
url = url + "&response_type=code&" + urlencode({'redirect_uri': redirect_uri})
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user