summary refs log tree commit diff
path: root/gateway/src/opcodes
diff options
context:
space:
mode:
Diffstat (limited to 'gateway/src/opcodes')
-rw-r--r--gateway/src/opcodes/Heartbeat.ts5
-rw-r--r--gateway/src/opcodes/Identify.ts16
-rw-r--r--gateway/src/opcodes/LazyRequest.ts5
-rw-r--r--gateway/src/opcodes/PresenceUpdate.ts3
-rw-r--r--gateway/src/opcodes/RequestGuildMembers.ts4
-rw-r--r--gateway/src/opcodes/Resume.ts5
-rw-r--r--gateway/src/opcodes/VoiceStateUpdate.ts4
-rw-r--r--gateway/src/opcodes/index.ts3
-rw-r--r--gateway/src/opcodes/instanceOf.ts3
9 files changed, 19 insertions, 29 deletions
diff --git a/gateway/src/opcodes/Heartbeat.ts b/gateway/src/opcodes/Heartbeat.ts

index 34d8ca74..46caee56 100644 --- a/gateway/src/opcodes/Heartbeat.ts +++ b/gateway/src/opcodes/Heartbeat.ts
@@ -1,7 +1,4 @@ -import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants"; -import { Send } from "@fosscord/gateway/util/Send"; -import { setHeartbeat } from "@fosscord/gateway/util/setHeartbeat"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { Payload, Send, setHeartbeat, WebSocket } from "@fosscord/gateway"; export async function onHeartbeat(this: WebSocket, data: Payload) { // TODO: validate payload diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index d91cd7f2..a58583ee 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts
@@ -1,5 +1,10 @@ -import { CLOSECODES, Payload, OPCODES } from "@fosscord/gateway/util/Constants"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { + WebSocket, + CLOSECODES, + Payload, + OPCODES, + genSessionId, +} from "@fosscord/gateway"; import { Channel, checkToken, @@ -24,7 +29,6 @@ import { Send } from "@fosscord/gateway/util/Send"; const experiments: any = []; import { check } from "./instanceOf"; import { Recipient } from "@fosscord/util"; -import { genSessionId } from "@fosscord/gateway/util/SessionUtils"; // TODO: bot sharding // TODO: check priviliged intents @@ -98,7 +102,9 @@ export async function onIdentify(this: WebSocket, data: Payload) { //TODO is this needed? check if users in group dm that are not friends are sent in the READY event //users = users.concat(x.channel.recipients); if (x.channel.isDm()) { - x.channel.recipients = x.channel.recipients!.filter((x) => x.id !== this.user_id); + x.channel.recipients = x.channel.recipients!.filter( + (x) => x.id !== this.user_id + ); } return x.channel; }); @@ -109,7 +115,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { if (!user) return this.close(CLOSECODES.Authentication_failed); for (let relation of user.relationships) { - const related_user = relation.to + const related_user = relation.to; const public_related_user = { username: related_user.username, discriminator: related_user.discriminator, diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts
index 41ec3446..db00157f 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts
@@ -2,13 +2,10 @@ import { getPermission, Member, PublicMemberProjection, - PublicUserProjection, Role, } from "@fosscord/util"; import { LazyRequest } from "../schema/LazyRequest"; -import { OPCODES, Payload } from "@fosscord/gateway/util/Constants"; -import { Send } from "@fosscord/gateway/util/Send"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { WebSocket, Send, OPCODES, Payload } from "@fosscord/gateway"; import { check } from "./instanceOf"; import "missing-native-js-functions"; diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/gateway/src/opcodes/PresenceUpdate.ts
index 4febbfcb..53d7b9d2 100644 --- a/gateway/src/opcodes/PresenceUpdate.ts +++ b/gateway/src/opcodes/PresenceUpdate.ts
@@ -1,5 +1,4 @@ -import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { WebSocket, Payload } from "@fosscord/gateway"; export function onPresenceUpdate(this: WebSocket, data: Payload) { // return this.close(CLOSECODES.Unknown_error); diff --git a/gateway/src/opcodes/RequestGuildMembers.ts b/gateway/src/opcodes/RequestGuildMembers.ts
index 9c1654fa..b80721dc 100644 --- a/gateway/src/opcodes/RequestGuildMembers.ts +++ b/gateway/src/opcodes/RequestGuildMembers.ts
@@ -1,6 +1,4 @@ -import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants"; - -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { Payload, WebSocket } from "@fosscord/gateway"; export function onRequestGuildMembers(this: WebSocket, data: Payload) { // return this.close(CLOSECODES.Unknown_error); diff --git a/gateway/src/opcodes/Resume.ts b/gateway/src/opcodes/Resume.ts
index e155c139..398cce25 100644 --- a/gateway/src/opcodes/Resume.ts +++ b/gateway/src/opcodes/Resume.ts
@@ -1,7 +1,4 @@ -import { CLOSECODES, Payload } from "@fosscord/gateway/util/Constants"; -import { Send } from "@fosscord/gateway/util/Send"; - -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { WebSocket, Payload, Send } from "@fosscord/gateway"; export async function onResume(this: WebSocket, data: Payload) { console.log("Got Resume -> cancel not implemented"); diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
index 60803ec3..084c5766 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -1,6 +1,5 @@ import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema"; -import { Payload } from "@fosscord/gateway/util/Constants"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { Payload, WebSocket, genVoiceToken } from "@fosscord/gateway"; import { check } from "./instanceOf"; import { Config, @@ -12,7 +11,6 @@ import { VoiceState, VoiceStateUpdateEvent, } from "@fosscord/util"; -import { genVoiceToken } from "@fosscord/gateway/util/SessionUtils"; // TODO: check if a voice server is setup // Notice: Bot users respect the voice channel's user limit, if set. When the voice channel is full, you will not receive the Voice State Update or Voice Server Update events in response to your own Voice State Update. Having MANAGE_CHANNELS permission bypasses this limit and allows you to join regardless of the channel being full or not. diff --git a/gateway/src/opcodes/index.ts b/gateway/src/opcodes/index.ts
index c4069589..027739db 100644 --- a/gateway/src/opcodes/index.ts +++ b/gateway/src/opcodes/index.ts
@@ -1,5 +1,4 @@ -import { Payload } from "@fosscord/gateway/util/Constants"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { WebSocket, Payload } from "@fosscord/gateway"; import { onHeartbeat } from "./Heartbeat"; import { onIdentify } from "./Identify"; import { onLazyRequest } from "./LazyRequest"; diff --git a/gateway/src/opcodes/instanceOf.ts b/gateway/src/opcodes/instanceOf.ts
index 6d84ac21..37d513ad 100644 --- a/gateway/src/opcodes/instanceOf.ts +++ b/gateway/src/opcodes/instanceOf.ts
@@ -1,6 +1,5 @@ import { instanceOf } from "lambert-server"; -import { CLOSECODES } from "@fosscord/gateway/util/Constants"; -import WebSocket from "@fosscord/gateway/util/WebSocket"; +import { WebSocket, CLOSECODES } from "@fosscord/gateway"; export function check(this: WebSocket, schema: any, data: any) { try {