-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helpers to retrieve the shard Id for guilds, and count how many guilds are handled by a Shard. Helpers to retrieve the shard Id of a guild have been added as: - `Guild::shard_id` - `GuildId::shard_id` These are in two forms: one working with the cache feature, and one without. The function that works with the cache will automatically retrieve the total number of shards from the Cache, while the uncached version requires passing in the total number of shards used. With the cache enabled, this might look like: ```rust guild.shard_id(); // which calls: guild_id.shard_id(); ``` Without the cache enabled, this looks like: ```rust let shard_count = 7; guild.shard_id(shard_count); // which calls: guild_id.shard_id(shard_count); ``` These two variants on `Guild` and `GuildId` are helper sugar methods over the new function `utils::shard_id`, which accepts a `guild_id` and a `shard_count`: ```rust use serenity::utils; assert_eq!(utils::shard_id(81384788765712384, 17), 7); ``` You would use `utils::shard_id` when you have the total number of shards due to `{Guild,GuildId}::shard_id` unlocking the cache to retrieve the total number of shards. This avoids some amount of work
- Loading branch information
Zeyla Hellyer
committed
Apr 13, 2017
1 parent
c4d0b58
commit 1561f9e
Showing
7 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters