{"_id":"577dc9b5781f3e0e005fb91d","user":"571193c63590a50e00bba99d","version":{"_id":"57590727ace5c30e00cb23d7","__v":2,"project":"571193ce8103870e00f48b67","createdAt":"2016-06-09T06:05:27.924Z","releaseDate":"2016-06-09T06:05:27.924Z","categories":["57590727ace5c30e00cb23d8","57590cd318760817001e8a83"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4.0.0"},"project":"571193ce8103870e00f48b67","category":{"_id":"57590727ace5c30e00cb23d8","__v":0,"version":"57590727ace5c30e00cb23d7","project":"571193ce8103870e00f48b67","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-04-16T01:22:22.642Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"__v":34,"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-07T03:17:09.153Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"The Voice Client allows the playback of audio in a Discord voice channel.\n\nTo join a voice channel, look [here](doc:discord#joinvoicechannelchannel-mute-deaf-monolog).\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"playFile($file, $channels)\"\n}\n[/block]\nPlays a file in the voice channel.\n\nReturns a ReactPHP promise which is resolved when the song is finished or stopped.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"h-3\": \"Default\",\n    \"0-0\": \"`$file`\",\n    \"0-1\": \"The file to play in the voice channel.\",\n    \"0-2\": \"`string`\",\n    \"0-3\": \"-\",\n    \"1-0\": \"`$channels`\",\n    \"1-1\": \"How many audio channels to encode the song with.\",\n    \"1-2\": \"`int`\",\n    \"1-3\": \"2\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {},\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"playRawStream($stream, $channels)\"\n}\n[/block]\nReads from a raw PCM16 (little endian) PHP stream (or ReactPHP stream) and plays it in the voice channel.\n\nReturns a ReactPHP promise which is resolved when the stream has finished.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"h-3\": \"Default\",\n    \"0-0\": \"`$stream`\",\n    \"0-1\": \"The stream to play.\",\n    \"0-2\": \"`resource` or ReactPHP stream.\",\n    \"0-3\": \"-\",\n    \"1-0\": \"`$channels`\",\n    \"1-1\": \"How many audio channels to encode the song with.\",\n    \"1-2\": \"`int`\",\n    \"1-3\": \"2\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"playDCAStream($stream)\"\n}\n[/block]\nReads from a [DCA1 Specification](https://github.com/bwmarrin/dca/wiki/DCA1-specification) stream and plays it in the voice channel.\n\nReturns a ReactPHP promise which is resolved when the stream has finished.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$stream`\",\n    \"0-1\": \"The stream to play.\",\n    \"0-2\": \"`resource, ReactPHP stream or ReactPHP process.\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setSpeaking($speaking)\"\n}\n[/block]\nSets whether the client is speaking. Automatically set when using a `play` function.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"h-3\": \"Default\",\n    \"0-0\": \"`$speaking`\",\n    \"0-1\": \"Whether the client is speaking.\",\n    \"0-2\": \"`bool`\",\n    \"0-3\": \"`true`\"\n  },\n  \"cols\": 4,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"switchChannel($channel)\"\n}\n[/block]\nSwitches the voice client to another channel.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$channel`\",\n    \"0-1\": \"The Voice Channel to switch to.\",\n    \"0-2\": \"[Channel](doc:channel)\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setFrameSize($fs)\"\n}\n[/block]\nSets the frame size of the opus packets. Valid options are `20`, `40` or `60` in milliseconds.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$fs`\",\n    \"0-1\": \"The frame size to set.\",\n    \"0-2\": \"`int`\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setBitrate($bitrate)\"\n}\n[/block]\nSets the bitrate of the audio. Must be between 8,000Hz and 128,000Hz. You cannot change the bitrate while the client is speaking.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$bitrate`\",\n    \"0-1\": \"The bitrate to set.\",\n    \"0-2\": \"`int`\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setVolume($volume)\"\n}\n[/block]\nSets the volume of the audio. Must be a percentage between 0% and 100%. You cannot change the volume while the client is speaking.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$volume`\",\n    \"0-1\": \"The volume to set.\",\n    \"0-2\": \"`int`\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setAudioApplication($app)\"\n}\n[/block]\nSets the Opus audio application. Valid options are `voip`, `audio` and `lowdelay`.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$app`\",\n    \"0-1\": \"The application to set.\",\n    \"0-2\": \"`string`\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"setMuteDeaf($mute, $deaf)\"\n}\n[/block]\nSets the mute/deaf status.\n\nReturns a ReactPHP promise.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$mute`\",\n    \"0-1\": \"Whether the client should be muted.\",\n    \"0-2\": \"`bool`\",\n    \"1-0\": \"`$deaf`\",\n    \"1-1\": \"Whether the client should be deafened.\",\n    \"1-2\": \"`bool`\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"pause()\"\n}\n[/block]\nPauses the audio, if it is playing.\n\nReturns a ReactPHP promise.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"unpause()\"\n}\n[/block]\nUn-pauses the audio if it is paused.\n\nReturns a ReactPHP promise.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"stop()\"\n}\n[/block]\nStops all audio playback.\n\nReturns a ReactPHP promise.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"close()\"\n}\n[/block]\nCloses the Voice Client.\n\nReturns a ReactPHP promise.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"isSpeaking($id)\"\n}\n[/block]\nChecks whether a user is speaking.\n\nReturns a boolean.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"0-0\": \"`$id`\",\n    \"0-1\": \"The user to check. Can be a Discord snowflake or a voice SSRC.\",\n    \"0-2\": \"`snowflake` or `int`.\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getReceiveStream($id)\"\n}\n[/block]\nGets a receive stream for a user.\n\nReturns a ReactPHP promise with a Receive Stream.","excerpt":"The Voice Client allows the playback of audio in a Discord voice channel.","slug":"voice-client","type":"basic","title":"Voice Client"}

Voice Client

The Voice Client allows the playback of audio in a Discord voice channel.

The Voice Client allows the playback of audio in a Discord voice channel. To join a voice channel, look [here](doc:discord#joinvoicechannelchannel-mute-deaf-monolog). [block:api-header] { "type": "fn", "title": "playFile($file, $channels)" } [/block] Plays a file in the voice channel. Returns a ReactPHP promise which is resolved when the song is finished or stopped. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$file`", "0-1": "The file to play in the voice channel.", "0-2": "`string`", "0-3": "-", "1-0": "`$channels`", "1-1": "How many audio channels to encode the song with.", "1-2": "`int`", "1-3": "2" }, "cols": 4, "rows": 2 } [/block] [block:parameters] { "data": {}, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "playRawStream($stream, $channels)" } [/block] Reads from a raw PCM16 (little endian) PHP stream (or ReactPHP stream) and plays it in the voice channel. Returns a ReactPHP promise which is resolved when the stream has finished. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$stream`", "0-1": "The stream to play.", "0-2": "`resource` or ReactPHP stream.", "0-3": "-", "1-0": "`$channels`", "1-1": "How many audio channels to encode the song with.", "1-2": "`int`", "1-3": "2" }, "cols": 4, "rows": 2 } [/block] [block:api-header] { "type": "fn", "title": "playDCAStream($stream)" } [/block] Reads from a [DCA1 Specification](https://github.com/bwmarrin/dca/wiki/DCA1-specification) stream and plays it in the voice channel. Returns a ReactPHP promise which is resolved when the stream has finished. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$stream`", "0-1": "The stream to play.", "0-2": "`resource, ReactPHP stream or ReactPHP process." }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setSpeaking($speaking)" } [/block] Sets whether the client is speaking. Automatically set when using a `play` function. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$speaking`", "0-1": "Whether the client is speaking.", "0-2": "`bool`", "0-3": "`true`" }, "cols": 4, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "switchChannel($channel)" } [/block] Switches the voice client to another channel. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$channel`", "0-1": "The Voice Channel to switch to.", "0-2": "[Channel](doc:channel)" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setFrameSize($fs)" } [/block] Sets the frame size of the opus packets. Valid options are `20`, `40` or `60` in milliseconds. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$fs`", "0-1": "The frame size to set.", "0-2": "`int`" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setBitrate($bitrate)" } [/block] Sets the bitrate of the audio. Must be between 8,000Hz and 128,000Hz. You cannot change the bitrate while the client is speaking. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$bitrate`", "0-1": "The bitrate to set.", "0-2": "`int`" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setVolume($volume)" } [/block] Sets the volume of the audio. Must be a percentage between 0% and 100%. You cannot change the volume while the client is speaking. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$volume`", "0-1": "The volume to set.", "0-2": "`int`" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setAudioApplication($app)" } [/block] Sets the Opus audio application. Valid options are `voip`, `audio` and `lowdelay`. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$app`", "0-1": "The application to set.", "0-2": "`string`" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "setMuteDeaf($mute, $deaf)" } [/block] Sets the mute/deaf status. Returns a ReactPHP promise. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$mute`", "0-1": "Whether the client should be muted.", "0-2": "`bool`", "1-0": "`$deaf`", "1-1": "Whether the client should be deafened.", "1-2": "`bool`" }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "type": "fn", "title": "pause()" } [/block] Pauses the audio, if it is playing. Returns a ReactPHP promise. [block:api-header] { "type": "fn", "title": "unpause()" } [/block] Un-pauses the audio if it is paused. Returns a ReactPHP promise. [block:api-header] { "type": "fn", "title": "stop()" } [/block] Stops all audio playback. Returns a ReactPHP promise. [block:api-header] { "type": "fn", "title": "close()" } [/block] Closes the Voice Client. Returns a ReactPHP promise. [block:api-header] { "type": "fn", "title": "isSpeaking($id)" } [/block] Checks whether a user is speaking. Returns a boolean. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$id`", "0-1": "The user to check. Can be a Discord snowflake or a voice SSRC.", "0-2": "`snowflake` or `int`." }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "getReceiveStream($id)" } [/block] Gets a receive stream for a user. Returns a ReactPHP promise with a Receive Stream.