-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (48 loc) · 1.59 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using DotNetEnv;
using Melon.Bot.Tasks;
using Melon.Services;
using NetCord.Hosting.Gateway;
using NetCord.Hosting.Services;
using NetCord.Hosting.Services.ApplicationCommands;
Env.Load();
await new Sqlite().CreateTable();
var builder = WebApplication.CreateBuilder(args);
builder
.Services.AddDiscordGateway(options =>
{
options.Token = Env.GetString("TOKEN");
})
.AddApplicationCommands();
builder.Services.AddSingleton<Sqlite>();
builder.Services.AddSingleton<Discord>();
builder.Services.AddSingleton<Melonly>();
builder.Services.AddHostedService<Refresh>();
WebApplication app = builder.Build();
app.Urls.Add($"http://{(Env.GetString("ENVIRONMENT") == "Production" ? "0.0.0.0" : "localhost")}:{Env.GetString("CALLBACK_PORT", "2742")}");
app.UseStaticFiles();
app.MapGet(
"/auth/callback",
async (HttpContext context) =>
{
return Results.Content(
"""
<!DOCTYPE html>
<html>
<head>
<title>Authorized</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-neutral-950 flex items-center justify-center min-h-screen">
<div class="text-center">
<h1 class="text-4xl font-bold text-green-600 mb-2">You're authorized!</h1>
<p class="text-gray-600">You can close this tab and return to Discord.</p>
</div>
</body>
</html>
""",
"text/html"
);
}
);
app.AddModules(typeof(Program).Assembly);
await app.RunAsync();