Releases: Hawxy/Discord.Addons.Hosting
v6.1.0
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.
v5.2.0
- Updated Discord.Net to v3.8.1 (Release notes)
- Removed references to Discord.Net.Labs & marked Discord.Net.Labs packages as end-of-life.
v5.1.0
v5.0.0 - Discord.Net v3.0.0
It's finally here!
Breaking Changes:
- Support for Discord.Net v3.0.0
- Only targets .NET 6, support for all prior targets has been dropped.
InitializedService
has been removed. See the v4 release notes for the relevant upgrade path.
New Features
- Added
UseInteractionService
HostBuilder extension that'll wire up anInteractionService
much in the same way thatUseCommandService
currently does.
.UseInteractionService((context, config) =>
{
config.LogLevel = LogSeverity.Info;
config.UseCompiledLambda = true;
})
- Support setting
ShardIds
within the sharded client configuration:
config.ShardIds = new[] { 1 };
See the v5.0.0 samples for further information.
v4.0.2: Discord.Net.Labs Edition
By popular demand. This release is identical to v4.0.2
but is binary compatible with Discord.Net.Labs. You can find it under the nuget pre-release tag of v4.0.2-labs
v4.0.2
v4.0.0 🚀
New Features:
- The Discord.NET sharded client is now supported. Use
ConfigureDiscordShardedHost
:
.ConfigureDiscordShardedHost((context, config) =>
{
config.SocketConfig = new DiscordSocketConfig
{
// Manually set the required shards, or leave empty for the recommended count
TotalShards = 4
};
config.Token = context.Configuration["token"];
})
A new example with the sharded client is also available.
WaitForReadyAsync
extensions have been added for the respective discord clients. This extension is designed for use within background services and will prevent continuation until the socket client ready event fires, or all shards have reached a ready state.
public class BotStatusService : DiscordClientService
{
public BotStatusService(DiscordSocketClient client, ILogger<DiscordClientService> logger) : base(client, logger)
{
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await Client.WaitForReadyAsync(stoppingToken);
Logger.LogInformation("Client is ready!");
await Client.SetActivityAsync(new Game("Set my status!"));
}
}
Breaking Changes:
ConfigureDiscordHost
no longer takes a generic parameter of client type:
- .ConfigureDiscordHost<DiscordSocketClient>((context, config) =>
+ .ConfigureDiscordHost((context, config) =>
InitializedService
is deprecated and replaced withDiscordClientService
. See the updated README docs for usage.
v3.1.1
v3.1.0
There are no public-facing API changes in this release.
-
Removed .NET Standard 2.0 target and added .NET 5 target. This drops support for .NET Core 2.x, however as I'm unable to find any public bot using both this package & .NET Core 2.x, this change shouldn't affect anyone. If you're consuming this package via a library project, target it to .NET Standard 2.1 or higher.
-
.NET 5 consumers will now receive the appropriate version of Microsoft.Extensions.Hosting. The version for 3.x consumers has also been bumped to latest.
-
Updated samples to .NET 5 and C# 9.
-
Misc internal fixes to quieten new roslyn warnings.