Command context's client Shard ID does not match guild's Shard ID
Created by: alexhorner
Summary
When you compare the Shard ID of the client from a command context to the Shard ID of the client retrieved using the context's Guild ID, they do not match.
Details
Running on 4.0.0-nightly-00833
packages across the board, .NET Core 3.1 on Windows 10 using Jetbrains Rider
Steps to reproduce
- Ensure your bot is in multiple guilds so that the bot can be accessed from multiple shards. I used 2 guilds.
- Inject the
DiscordShardedClient
intoCommandsNext
's DI ServiceCollection so you may access it in the constructor of a command module - Ensure the
DiscordShardedClient
is using more than one shard. For my test, I configured it to use 3 shards. - Create a command module extending
BaseCommandModule
and insert the following command[Command("testshardmatch")] public async Task TestShardMatch(CommandContext ctx) { //Assuming the DiscordShardedClient has been DI'd into the module as _shardedClient await ctx.RespondAsync($"Context shard ID is {ctx.Client.ShardId} and by guild ID shard ID is {_shardedClient.GetShard(ctx.Guild.Id).ShardId}"); }
- Execute this command for multiple guilds. You can find my examples in the notes. You should see that the IDs do not match