|
1 | 1 | using Gitcg.NetCord.MainApp.Components; |
| 2 | +using Gitcg.NetCord.MainApp.Infrastructure; |
| 3 | +using NetCord; |
| 4 | +using NetCord.Gateway; |
| 5 | +using NetCord.Hosting.Gateway; |
| 6 | +using NetCord.Hosting.Services.ApplicationCommands; |
| 7 | +using NetCord.Hosting.Services.ComponentInteractions; |
| 8 | +using NetCord.Services.ComponentInteractions; |
2 | 9 |
|
3 | 10 | var builder = WebApplication.CreateBuilder(args); |
4 | 11 |
|
5 | 12 | builder.AddServiceDefaults(); |
6 | 13 |
|
| 14 | +builder.AddRedisDistributedCache("redis"); |
| 15 | +builder.Services.AddHybridCache(); |
| 16 | + |
| 17 | +builder.AddNpgsqlDbContext<AppDbContext>("gitcgnetcorddb"); |
| 18 | + |
| 19 | +builder.Services |
| 20 | + .AddDiscordGateway(options => |
| 21 | + { |
| 22 | + options.Intents = GatewayIntents.All; |
| 23 | + }) |
| 24 | + .AddApplicationCommands() |
| 25 | + .AddComponentInteractions<ButtonInteraction, ButtonInteractionContext>() |
| 26 | + .AddComponentInteractions<StringMenuInteraction, StringMenuInteractionContext>() |
| 27 | + .AddComponentInteractions<UserMenuInteraction, UserMenuInteractionContext>() |
| 28 | + .AddComponentInteractions<RoleMenuInteraction, RoleMenuInteractionContext>() |
| 29 | + .AddComponentInteractions<MentionableMenuInteraction, MentionableMenuInteractionContext>() |
| 30 | + .AddComponentInteractions<ChannelMenuInteraction, ChannelMenuInteractionContext>() |
| 31 | + .AddComponentInteractions<ModalInteraction, ModalInteractionContext>(); |
| 32 | + |
7 | 33 | // Add services to the container. |
8 | 34 | builder.Services.AddRazorComponents() |
9 | 35 | .AddInteractiveServerComponents(); |
|
27 | 53 | app.MapRazorComponents<App>() |
28 | 54 | .AddInteractiveServerRenderMode(); |
29 | 55 |
|
| 56 | +app.AddSlashCommand( |
| 57 | + name: "ping", |
| 58 | + description: "Ping!", |
| 59 | + handler: () => "Pong!" |
| 60 | +); |
| 61 | + |
| 62 | +app.MapGet("/api/", () => "Hello World!"); |
| 63 | + |
| 64 | +app.UseGatewayHandlers(); |
| 65 | + |
30 | 66 | app.Run(); |
0 commit comments