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.