using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using NetCord.Gateway; using NetCord.Hosting.Gateway; using NetCord.Hosting.Services; using NetCord.Hosting.Services.ApplicationCommands; using StreakBot.Data; using StreakBot.Services; namespace StreakBot; public class Program { public static async Task Main(string[] args) { var dataPath = Environment.GetEnvironmentVariable("DATA_PATH") ?? "."; var connectionString = $"Data Source={Path.Combine(dataPath, "streaks.db")}"; var builder = Host.CreateDefaultBuilder(args) .ConfigureServices(services => { services.AddDbContext(options => options.UseSqlite(connectionString)); services.AddScoped(); services.AddScoped(); services.AddHostedService(); services.AddHostedService(); services.AddGatewayHandlers(typeof(Program).Assembly); }) .UseDiscordGateway(options => { options.Intents = GatewayIntents.Guilds | GatewayIntents.GuildMessages | GatewayIntents.MessageContent; }) .UseApplicationCommands(); var host = builder.Build(); using (var scope = host.Services.CreateScope()) { var db = scope.ServiceProvider.GetRequiredService(); await db.Database.MigrateAsync(); } host.AddSlashCommand("ping", "Ping!", () => "Pong!"); host.AddModules(typeof(Program).Assembly); await host.RunAsync(); } }