@require_setting('DISCORD_CLIENT_ID')
@login_required
def add_discord(request, code):
    project = _get_rw_project_for_user(request, code)
    state = token_urlsafe()
    auth_url = ('https://discordapp.com/api/oauth2/authorize?' + urlencode({'client_id': settings.DISCORD_CLIENT_ID, 'scope': 'webhook.incoming', 'redirect_uri': (settings.SITE_ROOT + reverse(add_discord_complete)), 'response_type': 'code', 'state': state}))
    ctx = {'page': 'channels', 'project': project, 'authorize_url': auth_url}
    request.session['add_discord'] = (state, str(project.code))
    return render(request, 'integrations/add_discord.html', ctx)
@require_setting('DISCORD_CLIENT_ID')
@login_required
def add_discord(request, code):
    project = _get_rw_project_for_user(request, code)
    state = token_urlsafe()
    auth_url = ('https://discordapp.com/api/oauth2/authorize?' + urlencode({'client_id': settings.DISCORD_CLIENT_ID, 'scope': 'webhook.incoming', 'redirect_uri': (settings.SITE_ROOT + reverse(add_discord_complete)), 'response_type': 'code', 'state': state}))
    ctx = {'page': 'channels', 'project': project, 'authorize_url': auth_url}
    request.session['add_discord'] = (state, str(project.code))
    return render(request, 'integrations/add_discord.html', ctx)