refactor: change xID to xId (#6036)

* refactor: change `xID` to `xId`

* Update src/managers/MessageManager.js

Co-authored-by: Noel <buechler.noel@outlook.com>

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Antonio Román
2021-07-04 20:54:27 +02:00
committed by GitHub
parent 281072be44
commit a7c6678c72
95 changed files with 963 additions and 963 deletions

View File

@@ -16,7 +16,7 @@ let Worker = null;
class Shard extends EventEmitter {
/**
* @param {ShardingManager} manager Manager that is creating this shard
* @param {number} id ID of this shard
* @param {number} id The shard's id
*/
constructor(manager, id) {
super();
@@ -31,7 +31,7 @@ class Shard extends EventEmitter {
this.manager = manager;
/**
* ID of the shard in the manager
* The shard's id in the manager
* @type {number}
*/
this.id = id;

View File

@@ -59,7 +59,7 @@ class ShardClientUtil {
}
/**
* Array of shard IDs of this client
* Array of shard ids of this client
* @type {number[]}
* @readonly
*/
@@ -230,14 +230,14 @@ class ShardClientUtil {
}
/**
* Get the shard ID for a given guild ID.
* @param {Snowflake} guildID Snowflake guild ID to get shard ID for
* Get the shard id for a given guild id.
* @param {Snowflake} guildId Snowflake guild id to get shard id for
* @param {number} shardCount Number of shards
* @returns {number}
*/
static shardIDForGuildID(guildID, shardCount) {
const shard = Number(BigInt(guildID) >> 22n) % shardCount;
if (shard < 0) throw new Error('SHARDING_SHARD_MISCALCULATION', shard, guildID, shardCount);
static shardIdForGuildId(guildId, shardCount) {
const shard = Number(BigInt(guildId) >> 22n) % shardCount;
if (shard < 0) throw new Error('SHARDING_SHARD_MISCALCULATION', shard, guildId, shardCount);
return shard;
}
}

View File

@@ -76,10 +76,10 @@ class ShardingManager extends EventEmitter {
throw new TypeError('CLIENT_INVALID_OPTION', 'shardList', 'an array.');
}
this.shardList = [...new Set(this.shardList)];
if (this.shardList.length < 1) throw new RangeError('CLIENT_INVALID_OPTION', 'shardList', 'at least 1 ID.');
if (this.shardList.length < 1) throw new RangeError('CLIENT_INVALID_OPTION', 'shardList', 'at least 1 id.');
if (
this.shardList.some(
shardID => typeof shardID !== 'number' || isNaN(shardID) || !Number.isInteger(shardID) || shardID < 0,
shardId => typeof shardId !== 'number' || isNaN(shardId) || !Number.isInteger(shardId) || shardId < 0,
)
) {
throw new TypeError('CLIENT_INVALID_OPTION', 'shardList', 'an array of positive integers.');
@@ -148,7 +148,7 @@ class ShardingManager extends EventEmitter {
/**
* Creates a single shard.
* <warn>Using this method is usually not necessary if you use the spawn method.</warn>
* @param {number} [id=this.shards.size] ID of the shard to create
* @param {number} [id=this.shards.size] Id of the shard to create
* <info>This is usually not necessary to manually specify.</info>
* @returns {Shard} Note that the created shard needs to be explicitly spawned using its spawn method.
*/
@@ -200,18 +200,18 @@ class ShardingManager extends EventEmitter {
this.totalShards = amount;
}
if (this.shardList.some(shardID => shardID >= amount)) {
if (this.shardList.some(shardId => shardId >= amount)) {
throw new RangeError(
'CLIENT_INVALID_OPTION',
'Amount of shards',
'bigger than the highest shardID in the shardList option.',
'bigger than the highest shardId in the shardList option.',
);
}
// Spawn the shards
for (const shardID of this.shardList) {
for (const shardId of this.shardList) {
const promises = [];
const shard = this.createShard(shardID);
const shard = this.createShard(shardId);
promises.push(shard.spawn(timeout));
if (delay > 0 && this.shards.size !== this.shardList.length) promises.push(Util.delayFor(delay));
await Promise.all(promises); // eslint-disable-line no-await-in-loop