summary refs log tree commit diff
path: root/src/gateway/opcodes/Identify.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/gateway/opcodes/Identify.ts')
-rw-r--r--src/gateway/opcodes/Identify.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 6aa152d3..f035fe15 100644
--- a/src/gateway/opcodes/Identify.ts
+++ b/src/gateway/opcodes/Identify.ts
@@ -16,7 +16,15 @@
 	along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-import { WebSocket, Payload, setupListener } from "@spacebar/gateway";
+import {
+	WebSocket,
+	Payload,
+	setupListener,
+	Capabilities,
+	CLOSECODES,
+	OPCODES,
+	Send,
+} from "@spacebar/gateway";
 import {
 	checkToken,
 	Intents,
@@ -45,11 +53,9 @@ import {
 	Permissions,
 	DMChannel,
 	GuildOrUnavailable,
+	Recipient,
 } from "@spacebar/util";
-import { Send } from "../util/Send";
-import { CLOSECODES, OPCODES } from "../util/Constants";
 import { check } from "./instanceOf";
-import { Recipient } from "@spacebar/util";
 
 // TODO: user sharding
 // TODO: check privileged intents, if defined in the config
@@ -73,6 +79,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 	check.call(this, IdentifySchema, data.d);
 	const identify: IdentifySchema = data.d;
 
+	this.capabilities = new Capabilities(identify.capabilities || 0);
+
 	// Check auth
 	// TODO: the checkToken call will fetch user, and then we have to refetch with different select
 	// checkToken should be able to select what we want
@@ -374,7 +382,9 @@ export async function onIdentify(this: WebSocket, data: Payload) {
 			: undefined,
 		user: user.toPrivateUser(),
 		user_settings: user.settings,
-		guilds: guilds.map((x) => new ReadyGuildDTO(x).toJSON()),
+		guilds: this.capabilities.has(Capabilities.FLAGS.CLIENT_STATE_V2)
+			? guilds.map((x) => new ReadyGuildDTO(x).toJSON())
+			: guilds,
 		relationships: user.relationships.map((x) => x.toPublicRelationship()),
 		read_state: {
 			entries: read_states,