1 /** 2 Utilties related to Discord Guild sharding. 3 */ 4 module dcord.util.sharding; 5 6 import dcord.types; 7 8 /** 9 Returns the shard number a given snowflake is on (given the number of shards), using the algorithm presented at https://discord.com/developers/docs/topics/gateway#sharding. 10 Params: 11 id = the Snowflake to find the shard number of 12 numShards = the number of total shards 13 */ 14 ushort shardNumber(Snowflake id, ushort numShards) { 15 return (id >> 22) % numShards; 16 }