diff --git a/voice/index.ts b/voice/index.ts new file mode 100644 index 0000000..9baa18c --- /dev/null +++ b/voice/index.ts @@ -0,0 +1,4 @@ +// This file exports all the types available in the recommended voice gateway version +// Thereby, things MAY break in the future. Try sticking to imports from a specific version + +export * from './v4'; \ No newline at end of file diff --git a/voice/v4.ts b/voice/v4.ts new file mode 100644 index 0000000..89b79fd --- /dev/null +++ b/voice/v4.ts @@ -0,0 +1,109 @@ +export const VoiceGatewayVersion = '4'; + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes + */ +export enum VoiceOpcodes { + /** + * Begin a voice websocket connection + */ + Identify, + /** + * Select the voice protocol + */ + SelectProtocol, + /** + * Complete the websocket handshake + */ + Ready, + /** + * Keep the websocket connection alive + */ + Heartbeat, + /** + * Describe the session + */ + SessionDescription, + /** + * Indicate which users are speaking + */ + Speaking, + /** + * Sent to acknowledge a received client heartbeat + */ + HeartbeatAck, + /** + * Resume a connection + */ + Resume, + /** + * Time to wait between sending heartbeats in milliseconds + */ + Hello, + /** + * Acknowledge a successful session resume + */ + Resumed, + /** + * A client has connected to the voice channel + */ + ClientConnect = 12, + /** + * A client has disconnected from the voice channel + */ + ClientDisconnect, +} + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes + */ +export enum VoiceCloseCodes { + /** + * You sent an invalid opcode + */ + UnknownOpcode = 4001, + /** + * You sent a invalid payload in your identifying to the Gateway + */ + FailedToDecode, + /** + * You sent a payload before identifying with the Gateway + */ + NotAuthenticated, + /** + * The token you sent in your identify payload is incorrect + */ + AuthenticationFailed, + /** + * You sent more than one identify payload. Stahp + */ + AlreadyAuthenticated, + /** + * Your session is no longer valid + */ + SessionNoLongerValid, + /** + * Your session has timed out + */ + SessionTimeout = 4009, + /** + * We can't find the server you're trying to connect to + */ + ServerNotFound = 4011, + /** + * We didn't recognize the protocol you sent + */ + UnknownProtocol, + /** + * Either the channel was deleted, you were kicked, or the main gateway session was dropped. Should not reconnect + */ + Disconnected = 4014, + /** + * The server crashed. Our bad! Try resuming + */ + VoiceServerCrashed, + /** + * We didn't recognize your encryption + */ + UnknownEncryptionMode, +} \ No newline at end of file