summary refs log tree commit diff
path: root/gateway/src/opcodes/VoiceStateUpdate.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-12 20:22:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-12 20:22:16 +0200
commit282f3cad7707610f4dfa6384313351dec7fdb2c7 (patch)
tree439bd33b5d436b28230a8a8b2f306d230d283cf6 /gateway/src/opcodes/VoiceStateUpdate.ts
parent1.3.52 (diff)
parent:sparkles: gateway (diff)
downloadserver-ts-282f3cad7707610f4dfa6384313351dec7fdb2c7.tar.xz
Merge branch 'master' into util
Diffstat (limited to 'gateway/src/opcodes/VoiceStateUpdate.ts')
-rw-r--r--gateway/src/opcodes/VoiceStateUpdate.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
new file mode 100644

index 00000000..0d51513d --- /dev/null +++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -0,0 +1,26 @@ +import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdate.ts"; +import { CLOSECODES, Payload } from "../util/Constants"; +import { Send } from "../util/Send"; + +import WebSocket from "../util/WebSocket"; +import { check } from "./instanceOf"; +// TODO: implementation +// TODO: check if a voice server is setup +// TODO: save voice servers in database and retrieve them +// 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. + +export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { + check.call(this, VoiceStateUpdateSchema, data.d); + const body = data.d as VoiceStateUpdateSchema; + + await Send(this, { + op: 0, + s: this.sequence++, + t: "VOICE_SERVER_UPDATE", + d: { + token: ``, + guild_id: body.guild_id, + endpoint: `localhost:3004`, + }, + }); +}