diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts
index acc39bb9..b675afcd 100644
--- a/gateway/src/events/Message.ts
+++ b/gateway/src/events/Message.ts
@@ -41,7 +41,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
return await OPCodeHandler.call(this, data);
} catch (error) {
console.error(error);
- if (!this.CLOSED && this.CLOSING)
+ // if (!this.CLOSED && this.CLOSING)
return this.close(CLOSECODES.Unknown_error);
}
}
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index 860000da..301f714d 100644
--- a/gateway/src/opcodes/Identify.ts
+++ b/gateway/src/opcodes/Identify.ts
@@ -35,6 +35,8 @@ import { Recipient } from "@fosscord/util";
export async function onIdentify(this: WebSocket, data: Payload) {
clearTimeout(this.readyTimeout);
+ if (typeof data.d?.client_state?.highest_last_message_id === "number")
+ data.d.client_state.highest_last_message_id += "";
check.call(this, IdentifySchema, data.d);
const identify: IdentifySchema = data.d;
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
index 321e6b17..ec4b1a92 100644
--- a/gateway/src/opcodes/VoiceStateUpdate.ts
+++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -58,6 +58,9 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
});
}
+ // 'Fix' for this one voice state error
+ if (!voiceState.guild_id) return;
+
//TODO the member should only have these properties: hoisted_role, deaf, joined_at, mute, roles, user
//TODO the member.user should only have these properties: avatar, discriminator, id, username
//TODO this may fail
@@ -65,7 +68,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
where: { id: voiceState.user_id, guild_id: voiceState.guild_id },
relations: ["user", "roles"],
});
-
+
//If the session changed we generate a new token
if (voiceState.session_id !== this.session_id)
voiceState.token = genVoiceToken();
diff --git a/gateway/src/schema/Identify.ts b/gateway/src/schema/Identify.ts
index 21141321..6aa93ce7 100644
--- a/gateway/src/schema/Identify.ts
+++ b/gateway/src/schema/Identify.ts
@@ -38,10 +38,11 @@ export const IdentifySchema = {
$capabilities: Number,
$client_state: {
$guild_hashes: Object,
- $highest_last_message_id: String,
+ $highest_last_message_id: String || Number,
$read_state_version: Number,
$user_guild_settings_version: Number,
$user_settings_version: undefined,
+ $useruser_guild_settings_version: Number,
},
$v: Number,
$version: Number,
@@ -80,10 +81,11 @@ export interface IdentifySchema {
capabilities?: number;
client_state?: {
guild_hashes?: any;
- highest_last_message_id?: string;
+ highest_last_message_id?: string | number;
read_state_version?: number;
user_guild_settings_version?: number;
user_settings_version?: number;
+ useruser_guild_settings_version?: number;
};
v?: number;
}
diff --git a/gateway/src/schema/VoiceStateUpdateSchema.ts b/gateway/src/schema/VoiceStateUpdateSchema.ts
index 9efa191e..f6480414 100644
--- a/gateway/src/schema/VoiceStateUpdateSchema.ts
+++ b/gateway/src/schema/VoiceStateUpdateSchema.ts
@@ -3,7 +3,8 @@ export const VoiceStateUpdateSchema = {
$channel_id: String,
self_mute: Boolean,
self_deaf: Boolean,
- self_video: Boolean,
+ $self_video: Boolean, //required in docs but bots don't always send it
+ $preferred_region: String,
};
export interface VoiceStateUpdateSchema {
@@ -11,5 +12,6 @@ export interface VoiceStateUpdateSchema {
channel_id?: string;
self_mute: boolean;
self_deaf: boolean;
- self_video: boolean;
-}
+ self_video?: boolean;
+ preferred_region?: string;
+}
\ No newline at end of file
diff --git a/gateway/src/util/Send.ts b/gateway/src/util/Send.ts
index c8627b03..c4202b21 100644
--- a/gateway/src/util/Send.ts
+++ b/gateway/src/util/Send.ts
@@ -6,7 +6,7 @@ try {
}
import { Payload, WebSocket } from "@fosscord/gateway";
-export async function Send(socket: WebSocket, data: Payload) {
+export function Send(socket: WebSocket, data: Payload) {
let buffer: Buffer | string;
if (socket.encoding === "etf") buffer = erlpack.pack(data);
// TODO: encode circular object
|