Command context's client Shard ID does not match guild's Shard ID
See original GitHub issueSummary
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
Notes
Guild A:
Guild B:
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Discord.js getting shards id - javascript
The error tells you that client.shards does not exist, that it is undefined . You cannot reference the property of that which does...
Read more >API Reference
shard_id ( int ) – The shard ID that requested being IDENTIFY'd ... doesn't require Intents.members within a guild context, but due to...
Read more >API Reference - nextcord
The default guild ids for every application command set. If the application command doesn't have any explicit guild ids set and this list...
Read more >DescribeStream - Amazon Kinesis Data Streams Service
To process shards in chronological order, use the ID of the parent shard to track the lineage to the oldest shard. This operation...
Read more >discord-hybrid-sharding
Example: A Discord bot with 4000 guilds Normally we would spawn 4 shards with the Sharding Manager ( ~4 x 300MB memory ),...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I see. As I am not at 1k yet, I decided to manually shard so I may test sharding is working with my code prior to it happening automatically. Thanks for taking a look at this!
@Neuheit The sharded client is injected like so: