def oauth_url(client_id, permissions=None, guild=None, redirect_uri=None):
url = '<STR_LIT>'.format(client_id)<EOL>if permissions is not None:<EOL><INDENT>url = url + '<STR_LIT>' + str(permissions.value)<EOL><DEDENT>if guild is not None:<EOL><INDENT>url = url + "<STR_LIT>" + str(guild.id)<EOL><DEDENT>if redirect_uri is not None:<EOL><INDENT>from urllib.parse import urlencode<EOL>url = url + "<STR_LIT>" + urlencode({'<STR_LIT>': redirect_uri})<EOL><DEDENT>return url<EOL>
A helper function that returns the OAuth2 URL for inviting the bot
    into guilds.

    Parameters
    -----------
    client_id: :class:`str`
        The client ID for your bot.
    permissions: :class:`Permissions`
        The permissions you're requesting. If not given then you won't be requesting any
        permissions.
    guild: :class:`Guild`
        The guild to pre-select in the authorization screen, if available.
    redirect_uri: :class:`str`
        An optional valid redirect URI.