init
This commit is contained in:
commit
ded4f4db26
43 changed files with 2052 additions and 0 deletions
71
Catalogger.Backend/Program.cs
Normal file
71
Catalogger.Backend/Program.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using Catalogger.Backend.Bot.Commands;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Extensions;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Remora.Commands.Extensions;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Commands;
|
||||
using Remora.Discord.Commands.Extensions;
|
||||
using Remora.Discord.Extensions.Extensions;
|
||||
using Remora.Discord.Gateway;
|
||||
using Remora.Discord.Hosting.Extensions;
|
||||
using Remora.Discord.Interactivity.Extensions;
|
||||
using Remora.Discord.Pagination.Extensions;
|
||||
using Serilog;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var config = builder.AddConfiguration();
|
||||
builder.AddSerilog();
|
||||
|
||||
builder.Services
|
||||
.AddControllers()
|
||||
.AddNewtonsoftJson(o => o.SerializerSettings.ContractResolver =
|
||||
new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new SnakeCaseNamingStrategy()
|
||||
});
|
||||
|
||||
builder.Host
|
||||
.AddDiscordService(_ => config.Discord.Token)
|
||||
.ConfigureServices(s =>
|
||||
s.AddRespondersFromAssembly(typeof(Program).Assembly)
|
||||
.Configure<DiscordGatewayClientOptions>(g =>
|
||||
g.Intents = GatewayIntents.Guilds |
|
||||
GatewayIntents.GuildBans |
|
||||
GatewayIntents.GuildInvites |
|
||||
GatewayIntents.GuildMembers |
|
||||
GatewayIntents.GuildMessages |
|
||||
GatewayIntents.GuildWebhooks |
|
||||
GatewayIntents.MessageContents |
|
||||
GatewayIntents.GuildEmojisAndStickers)
|
||||
.AddDiscordCommands(enableSlash: true)
|
||||
.AddCommandTree()
|
||||
// Start command tree
|
||||
.WithCommandGroup<MetaCommands>()
|
||||
// End command tree
|
||||
.Finish()
|
||||
.AddPagination()
|
||||
.AddInteractivity()
|
||||
);
|
||||
|
||||
builder.Services
|
||||
.AddDbContext<DatabaseContext>()
|
||||
.AddCustomServices()
|
||||
.AddEndpointsApiExplorer()
|
||||
.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await app.Initialize();
|
||||
|
||||
app.UseSerilogRequestLogging();
|
||||
app.UseRouting();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseCors();
|
||||
app.MapControllers();
|
||||
|
||||
app.Urls.Clear();
|
||||
app.Urls.Add(config.Web.Address);
|
||||
|
||||
app.Run();
|
||||
Log.CloseAndFlush();
|
||||
Loading…
Add table
Add a link
Reference in a new issue