<?php
require "db.php";

$client_id = "1500663655707185182";
$redirect_uri = "https://rewire.kryptondev.com/Auth/discord_callback.php";

$state = bin2hex(random_bytes(16));
$_SESSION["discord_state"] = $state;

$params = http_build_query([
    "client_id" => $client_id,
    "redirect_uri" => $redirect_uri,
    "response_type" => "code",
    "scope" => "identify email",
    "state" => $state
]);

header("Location: https://discord.com/oauth2/authorize?$params");
exit;