refactor(ShardClientUtil): logic de-duplication (#9491)

added docs to the `calculateShardId` function
This commit is contained in:
Almeida
2023-05-01 21:08:45 +01:00
committed by GitHub
parent 54ceedf6c5
commit a9f2bff82a
2 changed files with 9 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
/**
* Calculates the shard id for a given guild id.
*
* @param guildId - The guild id to calculate the shard id for
* @param shardCount - The total number of shards
*/
export function calculateShardId(guildId: string, shardCount: number) {
return Number((BigInt(guildId) >> 22n) % BigInt(shardCount));
return Number(BigInt(guildId) >> 22n) % shardCount;
}