using System.Text.Json.Serialization; using Microsoft.Extensions.Caching.Memory; using NetCord; using NetCord.Gateway; using NetCord.Hosting.Gateway; using NetCord.Hosting.Rest; using SquadBot.Handlers; using SquadBot.StateMangers; namespace SquadBot; public class Program { public static async Task Main(string[] args) { var token = ""; var pubkey = ""; if (args.Length == 2) { token = args[0]; pubkey = args[1]; } else { Console.Error.WriteLine("Usage: squadbot "); } var builder = Host.CreateApplicationBuilder(args); builder.Services.AddLogging(); builder.Services.AddDiscordRest(options => { options.PublicKey = pubkey; options.Token = token; }); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(new MemoryCache(new MemoryCacheOptions())); builder.Services.AddDiscordGateway(options => { options.Intents = GatewayIntents.GuildMessages | GatewayIntents.GuildVoiceStates; options.Token = token; }) .AddGatewayHandlers(typeof(Program).Assembly); var host = builder.Build() .UseGatewayHandlers(); await host.RunAsync(); } }