summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-08 17:46:40 +0100
committerRory& <root@rory.gay>2026-03-20 18:17:41 +0100
commit9597ebe941a95c18b57fe72c8b667981d1b7d6ea (patch)
tree17be6e5fab37a39b7570fb3c6509757e9a3b48ea
parentMigrate Invite*Event to satisfies, part of #1577 (diff)
downloadserver-ts-9597ebe941a95c18b57fe72c8b667981d1b7d6ea.tar.xz
Migrate VoiceS*Event to satisfies, part of #1577
-rw-r--r--src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts8
-rw-r--r--src/gateway/events/Close.ts4
-rw-r--r--src/gateway/opcodes/StreamCreate.ts7
-rw-r--r--src/gateway/opcodes/StreamDelete.ts8
-rw-r--r--src/gateway/opcodes/VoiceStateUpdate.ts4
5 files changed, 22 insertions, 9 deletions
diff --git a/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts

index 95c39283..3b310325 100644 --- a/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts +++ b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts
@@ -65,6 +65,7 @@ router.patch( channel_id: body.channel_id, user_id, }, + relations: { member: true }, }); if (!voice_state) throw DiscordApiErrors.UNKNOWN_VOICE_STATE; @@ -80,9 +81,12 @@ router.patch( voice_state.save(), emitEvent({ event: "VOICE_STATE_UPDATE", - data: voice_state.toPublicVoiceState(), + data: { + ...voice_state.toPublicVoiceState(), + member: voice_state.member.toPublicMember(), + }, guild_id, - } as VoiceStateUpdateEvent), + } satisfies VoiceStateUpdateEvent), ]); return res.sendStatus(204); }, diff --git a/src/gateway/events/Close.ts b/src/gateway/events/Close.ts
index 2f30564c..adbf9be7 100644 --- a/src/gateway/events/Close.ts +++ b/src/gateway/events/Close.ts
@@ -32,6 +32,7 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) { const voiceState = await VoiceState.findOne({ where: { user_id: this.user_id }, + relations: { member: true }, }); // clear the voice state for this session if user was in voice channel @@ -53,10 +54,11 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) { data: { ...voiceState.toPublicVoiceState(), guild_id: prevGuildId, // have to send the previous guild_id because that's what client expects for disconnect messages + member: voiceState.member.toPublicMember(), }, guild_id: prevGuildId, channel_id: prevChannelId, - } as VoiceStateUpdateEvent); + } satisfies VoiceStateUpdateEvent); } } diff --git a/src/gateway/opcodes/StreamCreate.ts b/src/gateway/opcodes/StreamCreate.ts
index cd3c4b77..69d4619d 100644 --- a/src/gateway/opcodes/StreamCreate.ts +++ b/src/gateway/opcodes/StreamCreate.ts
@@ -108,10 +108,13 @@ export async function onStreamCreate(this: WebSocket, data: Payload) { await emitEvent({ event: "VOICE_STATE_UPDATE", - data: voiceState.toPublicVoiceState(), + data: { + ...voiceState.toPublicVoiceState(), + member: voiceState.member.toPublicMember(), + }, guild_id: voiceState.guild_id, channel_id: voiceState.channel_id, - } as VoiceStateUpdateEvent); + } satisfies VoiceStateUpdateEvent); console.log(`[Gateway/${this.user_id}] STREAM_CREATE for user ${this.user_id} in channel ${body.channel_id} with stream key ${streamKey} in ${Date.now() - startTime}ms`); } diff --git a/src/gateway/opcodes/StreamDelete.ts b/src/gateway/opcodes/StreamDelete.ts
index 6135e1f3..66db34e7 100644 --- a/src/gateway/opcodes/StreamDelete.ts +++ b/src/gateway/opcodes/StreamDelete.ts
@@ -47,6 +47,7 @@ export async function onStreamDelete(this: WebSocket, data: Payload) { const voiceState = await VoiceState.findOne({ where: { user_id: this.user_id }, + relations: { member: true }, }); if (voiceState) { @@ -55,10 +56,13 @@ export async function onStreamDelete(this: WebSocket, data: Payload) { await emitEvent({ event: "VOICE_STATE_UPDATE", - data: voiceState.toPublicVoiceState(), + data: { + ...voiceState.toPublicVoiceState(), + member: voiceState.member.toPublicMember(), + }, guild_id: guildId, channel_id: channelId, - } as VoiceStateUpdateEvent); + } satisfies VoiceStateUpdateEvent); } await emitEvent({ diff --git a/src/gateway/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts
index 678afad8..4c34cccc 100644 --- a/src/gateway/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts
@@ -118,7 +118,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { guild_id: voiceState.guild_id, channel_id: voiceState.channel_id, user_id: voiceState.user_id, - } as VoiceStateUpdateEvent), + } satisfies VoiceStateUpdateEvent), ]); //If it's null it means that we are leaving the channel and this event is not needed @@ -153,7 +153,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { channel_id: voiceState.guild_id ? undefined : voiceState.channel_id, // only DM voice calls have this set, and DM channel is one where guild_id is null }, user_id: voiceState.user_id, - } as VoiceServerUpdateEvent); + } satisfies VoiceServerUpdateEvent); } console.log(