Repository: discordjs/voice
Pull request #156 (2021-07-20 13:02:14)

refactor(ConnectionOptions): change `xID` to `xId`
**Please describe the changes this PR makes and why it should be merged:**
This changes all mentions of `xID` in ConnectionOptions to `xId` for consistency with everything else


**Status and versioning classification:**
- This PR changes the library's interface (methods or parameters added)
- This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
<!--
Please move lines that apply to you out of the comment:
- Code changes have been tested against the Discord API, or there are no code changes
- This PR **only** includes non-code changes, like changes to documentation, README, etc.
-->


codecov[bot]: # [Codecov](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs) Report
> Merging [#156](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs) (02bc0ae) into [main](https://codecov.io/gh/discordjs/voice/commit/9f09caa601ff8ece63ae3e0649b01d62c8bf16c9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs) (9f09caa) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/discordjs/voice/pull/156/graphs/tree.svg?width=650&height=150&src=pr&token=u7oQ23UoxX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs)](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs)

```diff
@@           Coverage Diff           @@
##             main     #156   +/-   ##
=======================================
  Coverage   68.65%   68.65%           
=======================================
  Files          19       19           
  Lines         906      906           
  Branches      221      221           
=======================================
  Hits          622      622           
  Misses        282      282           
  Partials        2        2           
```


| [Impacted Files](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs) | Coverage Δ | |
|---|---|---|
| [src/networking/Networking.ts](https://codecov.io/gh/discordjs/voice/pull/156/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs#diff-c3JjL25ldHdvcmtpbmcvTmV0d29ya2luZy50cw==) | `3.64% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs). Last update [9f09caa...02bc0ae](https://codecov.io/gh/discordjs/voice/pull/156?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=discordjs).


Patch:
diff --git a/examples/basic/adapter.ts b/examples/basic/adapter.ts
index 2dd94f9..87eff80 100644
--- a/examples/basic/adapter.ts
+++ b/examples/basic/adapter.ts
@@ -27,8 +27,8 @@ const trackedGuilds = new Map<WebSocketShard, Set<Snowflake>>();
 function cleanupGuilds(shard: WebSocketShard) {
 	const guilds = trackedGuilds.get(shard);
 	if (guilds) {
-		for (const guildID of guilds.values()) {
-			adapters.get(guildID)?.destroy();
+		for (const guildId of guilds.values()) {
+			adapters.get(guildId)?.destroy();
 		}
 	}
 }
diff --git a/examples/music-bot/src/bot.ts b/examples/music-bot/src/bot.ts
index 377a16c..57f08cd 100644
--- a/examples/music-bot/src/bot.ts
+++ b/examples/music-bot/src/bot.ts
@@ -68,8 +68,8 @@ const subscriptions = new Map<Snowflake, MusicSubscription>();
 
 // Handles slash command interactions
 client.on('interaction', async (interaction: Interaction) => {
-	if (!interaction.isCommand() || !interaction.guildID) return;
-	let subscription = subscriptions.get(interaction.guildID);
+	if (!interaction.isCommand() || !interaction.guildId) return;
+	let subscription = subscriptions.get(interaction.guildId);
 
 	if (interaction.commandName === 'play') {
 		await interaction.defer();
@@ -89,7 +89,7 @@ client.on('interaction', async (interaction: Interaction) => {
 					}),
 				);
 				subscription.voiceConnection.on('error', console.warn);
-				subscriptions.set(interaction.guildID, subscription);
+				subscriptions.set(interaction.guildId, subscription);
 			}
 		}
 
@@ -173,7 +173,7 @@ client.on('interaction', async (interaction: Interaction) => {
 	} else if (interaction.commandName === 'leave') {
 		if (subscription) {
 			subscription.voiceConnection.destroy();
-			subscriptions.delete(interaction.guildID);
+			subscriptions.delete(interaction.guildId);
 			await interaction.reply({ content: `Left channel!`, ephemeral: true });
 		} else {
 			await interaction.reply('Not playing in this server!');
diff --git a/src/VoiceConnection.ts b/src/VoiceConnection.ts
index 2700500..de9ca07 100644
--- a/src/VoiceConnection.ts
+++ b/src/VoiceConnection.ts
@@ -334,10 +334,10 @@ export class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
 		const networking = new Networking(
 			{
 				endpoint: server.endpoint,
-				serverID: server.guild_id,
+				serverId: server.guild_id,
 				token: server.token,
-				sessionID: state.session_id,
-				userID: state.user_id,
+				sessionId: state.session_id,
+				userId: state.user_id,
 			},
 			Boolean(this.debug),
 		);
diff --git a/src/networking/Networking.ts b/src/networking/Networking.ts
index 98552ee..3b34f3b 100644
--- a/src/networking/Networking.ts
+++ b/src/networking/Networking.ts
@@ -122,9 +122,9 @@ export type NetworkingState =
  * and VOICE_STATE_UPDATE packets.
  */
 interface ConnectionOptions {
-	serverID: string;
-	userID: string;
-	sessionID: string;
+	serverId: string;
+	userId: string;
+	sessionId: string;
 	token: string;
 	endpoint: string;
 }
@@ -284,9 +284,9 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
 			const packet = {
 				op: VoiceOpcodes.Identify,
 				d: {
-					server_id: this.state.connectionOptions.serverID,
-					user_id: this.state.connectionOptions.userID,
-					session_id: this.state.connectionOptions.sessionID,
+					server_id: this.state.connectionOptions.serverId,
+					user_id: this.state.connectionOptions.userId,
+					session_id: this.state.connectionOptions.sessionId,
 					token: this.state.connectionOptions.token,
 				},
 			};
@@ -299,8 +299,8 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
 			const packet = {
 				op: VoiceOpcodes.Resume,
 				d: {
-					server_id: this.state.connectionOptions.serverID,
-					session_id: this.state.connectionOptions.sessionID,
+					server_id: this.state.connectionOptions.serverId,
+					session_id: this.state.connectionOptions.sessionId,
 					token: this.state.connectionOptions.token,
 				},
 			};


Test patch:
diff --git a/src/__tests__/VoiceConnection.test.ts b/src/__tests__/VoiceConnection.test.ts
index 37db1e2..296ae9b 100644
--- a/src/__tests__/VoiceConnection.test.ts
+++ b/src/__tests__/VoiceConnection.test.ts
@@ -320,10 +320,10 @@ describe('VoiceConnection#configureNetworking', () => {
 		expect(Networking.Networking).toHaveBeenCalledWith(
 			{
 				endpoint: server.endpoint,
-				serverID: server.guild_id,
+				serverId: server.guild_id,
 				token: server.token,
-				sessionID: state.session_id,
-				userID: state.user_id,
+				sessionId: state.session_id,
+				userId: state.user_id,
 			},
 			false,
 		);