Skip to content

Commit 0784add

Browse files
s074TheArcaneBrony
authored andcommitted
onVoiceStateUpdate: change to VoiceState.merge() for copying properties
1 parent 2ee3a01 commit 0784add

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/gateway/opcodes/VoiceStateUpdate.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
6161
//The event send by Discord's client on channel leave has both guild_id and channel_id as null
6262
//if (body.guild_id === null) body.guild_id = voiceState.guild_id;
6363
prevState = { ...voiceState };
64-
voiceState.assign(body);
64+
VoiceState.merge(voiceState, body);
6565
} catch (error) {
6666
voiceState = VoiceState.create({
6767
...body,
@@ -70,6 +70,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
7070
mute: false,
7171
suppress: false,
7272
});
73+
isChanged = true;
7374
}
7475

7576
// if user left voice channel, send an update to previous channel/guild to let other people know that the user left
@@ -90,10 +91,14 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
9091
//TODO the member.user should only have these properties: avatar, discriminator, id, username
9192
//TODO this may fail
9293
if (body.guild_id) {
93-
voiceState.member = await Member.findOneOrFail({
94+
const member = await Member.findOne({
9495
where: { id: voiceState.user_id, guild_id: voiceState.guild_id },
9596
relations: { user: true, roles: true },
9697
});
98+
99+
if (member) {
100+
voiceState.member = member;
101+
}
97102
}
98103

99104
//If the session changed we generate a new token

0 commit comments

Comments
 (0)