Repository navigation
v6.0.0
Feature Updates
This release marks the IHostBuilder extensions as obsolete and replaces them with IServiceCollection alternatives (Closes #29). This allows for easier support of .NET 7+ IHostApplicationBuilder environments. The previous extensions will continue to work for the v6 lifecycle, however if you're interested in moving to the new extensions there's one of two options:
- Move to the new
Host.CreateApplicationBuilder-based configuration model (Recommended):
Before
var host = Host.CreateDefaultBuilder()
.ConfigureDiscordHost((context, config) =>
{
config.SocketConfig = new DiscordSocketConfig
{
LogLevel = LogSeverity.Verbose,
AlwaysDownloadUsers = true,
MessageCacheSize = 200
};
config.Token = context.Configuration["token"];
})
.UseCommandService((context, config) =>
{
config.DefaultRunMode = RunMode.Async;
config.CaseSensitiveCommands = false;
})
.UseInteractionService((context, config) =>
{
config.LogLevel = LogSeverity.Info;
config.UseCompiledLambda = true;
})
.ConfigureServices((context, services) =>
{
services.AddHostedService<CommandHandler>();
services.AddHostedService<BotStatusService>();
services.AddHostedService<LongRunningService>();
}).Build();
await host.RunAsync();After
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddDiscordHost((config, _) =>
{
config.SocketConfig = new DiscordSocketConfig
{
LogLevel = LogSeverity.Verbose,
AlwaysDownloadUsers = true,
MessageCacheSize = 200,
GatewayIntents = GatewayIntents.All
};
config.Token = builder.Configuration["Token"]!;
});
builder.Services.AddCommandService((config, _) =>
{
config.DefaultRunMode = RunMode.Async;
config.CaseSensitiveCommands = false;
});
builder.Services.AddInteractionService((config, _) =>
{
config.LogLevel = LogSeverity.Info;
config.UseCompiledLambda = true;
});
builder.Services.AddHostedService<CommandHandler>();
builder.Services.AddHostedService<InteractionHandler>();
builder.Services.AddHostedService<BotStatusService>();
builder.Services.AddHostedService<LongRunningService>();
var host = builder.Build();
await host.RunAsync();- Or, call the new extensions within
.ConfigureServices((context, services) => //...):
.ConfigureServices((context, services) =>
{
services.AddDiscordHost((config, _) =>
{
// ...
});
})- Improved the validation message when an invalid token is provided. (Closes #30)
- Minimum Discord.Net version is now v3.12.