Update code for latest nightly builds #167
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A couple of noteworthy changes here:
Reflection is no longer used to hook events - the handlers are now triggered through a transient service as part of DSharpPlus' new event handler implementations
Connected shard count retrieval still has default implementations, but if an end-user is using a custom
IShardOrchestrator
implementation, for the most accurate shard count retrieval they should supply their own Task.Example:
builder.Services.Configure<DiscordClientWrapper>(wrapper => wrapper.GetShardCount = () => YourTask());
Additionally, if your shard count retrieval needs to make asynchronous calls:
builder.Services.Configure<DiscordClientWrapper>(wrapper => wrapper.GetShardCount = async () => await YourTaskAsync());
Obviously you can skip the lambda expressions and directly insert the method name, but I used lambda here to make it more obvious what's actually being done.
This won't be relevant for 99% (if not 100%) of users, as D#+'s default implementations are usually more than fine enough. However, I'm still going to reach out to D#+ to see about implementing a connected shard count property or method on the
IShardOrchestrator
interface. This would allow us to forego all of this extra roundabout retrieval and directly access the counts without the need for any additional configuration from end users.