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(
|