using AnsonBot.Client.Pages;
using AnsonBot.Components;
using Discord;
using Discord.WebSocket;
using Newtonsoft.Json.Linq;

var builder = WebApplication.CreateBuilder(args);

DiscordSocketConfig config = new()
{
    GatewayIntents = GatewayIntents.All | GatewayIntents.GuildMembers | GatewayIntents.GuildBans
};

DiscordSocketClient _client = new(config);
var token = "MTUyNjk1Njk4MTM5MzI5MzQxMg.G46bg4.RTqBp1gvtEirLUtbojdpktz9MCZF76Sm4ecqOo";
await _client.LoginAsync(TokenType.Bot, token);
await _client.StartAsync();

builder.Services.AddSingleton(config);
builder.Services.AddSingleton<DiscordSocketClient>(_client);

// Add services to the container.
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents()
    .AddInteractiveWebAssemblyComponents();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseWebAssemblyDebugging();
}
else
{
    app.UseExceptionHandler("/Error", createScopeForErrors: true);
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.UseHttpsRedirection();

app.UseAntiforgery();

app.MapStaticAssets();
app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .AddInteractiveWebAssemblyRenderMode()
    .AddAdditionalAssemblies(typeof(AnsonBot.Client._Imports).Assembly);

app.Run();
