{"_id":"577db72347a9ab0e003dff46","project":"571193ce8103870e00f48b67","__v":10,"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"},"user":"571193c63590a50e00bba99d","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-07T01:57:55.038Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"The Discord class is the base of the client.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Attributes\"\n}\n[/block]\n\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 unique identifier of the bot/user.\",\n    \"0-2\": \"snowflake\",\n    \"1-0\": \"username\",\n    \"1-1\": \"The username of the bot/user.\",\n    \"1-2\": \"string\",\n    \"2-0\": \"verified\",\n    \"2-1\": \"Whether the account is verified.\",\n    \"2-2\": \"bool\",\n    \"3-0\": \"avatar\",\n    \"3-1\": \"The URL to the bot/user's avatar.\",\n    \"3-2\": \"string\",\n    \"5-0\": \"discriminator\",\n    \"5-1\": \"A unique integer that discriminates users with the same username, often referred to as a \\\"Discord Tag\\\".\",\n    \"5-2\": \"int\",\n    \"6-0\": \"bot\",\n    \"6-1\": \"Whether the user is a bot account.\",\n    \"6-2\": \"bool\",\n    \"7-0\": \"user\",\n    \"7-1\": \"The user of the client.\",\n    \"7-2\": \"[User](doc:user)\",\n    \"8-0\": \"application\",\n    \"8-1\": \"The OAuth application the bot belongs to.\",\n    \"8-2\": \"[Application](doc:application)\",\n    \"4-0\": \"avatar_hash\",\n    \"4-1\": \"The avatar hash of the bot/user.\",\n    \"4-2\": \"string\"\n  },\n  \"cols\": 3,\n  \"rows\": 9\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"run()\"\n}\n[/block]\nStarts the ReactPHP event loop and the bot.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"close()\"\n}\n[/block]\nCloses the DiscordPHP client.\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"factory($class, $data)\"\n}\n[/block]\nProvides access to the class factory.\n\nReturns an instance of `$class`.\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\": \"`$class`\",\n    \"0-1\": \"The class to create. Must be a Part or a Repository.\",\n    \"0-2\": \"`string`\",\n    \"0-3\": \"-\",\n    \"1-0\": \"`$data`\",\n    \"1-1\": \"An array of data to put into the Part.\",\n    \"1-2\": \"`array`\",\n    \"1-3\": \"`[]`\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$channel = $discord->factory(Channel::class, ['name' => 'newchannel']);\",\n      \"language\": \"php\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"updatePresence($game, $idle)\"\n}\n[/block]\nUpdates the presence of the bot.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"h-2\": \"Type\",\n    \"h-3\": \"Default\",\n    \"0-0\": \"`$game`\",\n    \"0-1\": \"The game object to set.\",\n    \"0-2\": \"`Game`\",\n    \"0-3\": \"`null`\",\n    \"1-0\": \"`$idle`\",\n    \"1-1\": \"Whether the client should be set to idle.\",\n    \"1-2\": \"`bool`\",\n    \"1-3\": \"`false`\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$game = $discord->factory(Game::class, [\\n    'name' => 'i am playing a game!',\\n]);\\n\\n$discord->updatePresence($game);\",\n      \"language\": \"php\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"joinVoiceChannel($channel, $mute, $deaf, $monolog)\"\n}\n[/block]\nAttempts to connect to a voice channel.\n\nReturns a Promise with a [Voice Client](doc:voiceclient).\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\": \"`$channel`\",\n    \"0-1\": \"The Voice Channel to join.\",\n    \"0-2\": \"[Channel](doc:channel)\",\n    \"0-3\": \"-\",\n    \"1-0\": \"`$mute`\",\n    \"1-1\": \"Whether the client should be self-muted.\",\n    \"1-2\": \"`bool`\",\n    \"1-3\": \"`false`\",\n    \"2-0\": \"`$deaf`\",\n    \"2-1\": \"Whether the client should be self-deafened.\",\n    \"2-2\": \"`bool`\",\n    \"2-3\": \"`true`\",\n    \"3-0\": \"`$monolog`\",\n    \"3-1\": \"The Monolog logger to use.\",\n    \"3-2\": \"`Monolog`\",\n    \"3-3\": \"`null`\"\n  },\n  \"cols\": 4,\n  \"rows\": 4\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$discord->joinVoiceChannel($channel)->then(function (VoiceClient $vc) {\\n    echo \\\"Joined voice channel.\\\\r\\\\n\\\";\\n    $vc->playFile('myfile.mp3');\\n}, function ($e) {\\n    echo \\\"There was an error joining the voice channel: {$e->getMessage()}\\\\r\\\\n\\\"; \\n});\",\n      \"language\": \"php\",\n      \"name\": \"Example\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getVoiceClient($id)\"\n}\n[/block]\nAttempts to retrieve a voice client.\n\nReturns a Promise with a [Voice Client](doc:voiceclient)\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 channel ID to look for.\",\n    \"0-2\": \"`snowflake`\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","excerpt":"The Discord class is the base of the client.","slug":"discord","type":"basic","title":"Discord"}

Discord

The Discord class is the base of the client.

The Discord class is the base of the client. [block:api-header] { "type": "basic", "title": "Attributes" } [/block] [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "id", "0-1": "The unique identifier of the bot/user.", "0-2": "snowflake", "1-0": "username", "1-1": "The username of the bot/user.", "1-2": "string", "2-0": "verified", "2-1": "Whether the account is verified.", "2-2": "bool", "3-0": "avatar", "3-1": "The URL to the bot/user's avatar.", "3-2": "string", "5-0": "discriminator", "5-1": "A unique integer that discriminates users with the same username, often referred to as a \"Discord Tag\".", "5-2": "int", "6-0": "bot", "6-1": "Whether the user is a bot account.", "6-2": "bool", "7-0": "user", "7-1": "The user of the client.", "7-2": "[User](doc:user)", "8-0": "application", "8-1": "The OAuth application the bot belongs to.", "8-2": "[Application](doc:application)", "4-0": "avatar_hash", "4-1": "The avatar hash of the bot/user.", "4-2": "string" }, "cols": 3, "rows": 9 } [/block] [block:api-header] { "type": "fn", "title": "run()" } [/block] Starts the ReactPHP event loop and the bot. [block:api-header] { "type": "fn", "title": "close()" } [/block] Closes the DiscordPHP client. [block:api-header] { "type": "fn", "title": "factory($class, $data)" } [/block] Provides access to the class factory. Returns an instance of `$class`. [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$class`", "0-1": "The class to create. Must be a Part or a Repository.", "0-2": "`string`", "0-3": "-", "1-0": "`$data`", "1-1": "An array of data to put into the Part.", "1-2": "`array`", "1-3": "`[]`" }, "cols": 4, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "<?php\n\n$channel = $discord->factory(Channel::class, ['name' => 'newchannel']);", "language": "php", "name": "Example" } ] } [/block] [block:api-header] { "type": "fn", "title": "updatePresence($game, $idle)" } [/block] Updates the presence of the bot. [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$game`", "0-1": "The game object to set.", "0-2": "`Game`", "0-3": "`null`", "1-0": "`$idle`", "1-1": "Whether the client should be set to idle.", "1-2": "`bool`", "1-3": "`false`" }, "cols": 4, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "<?php\n\n$game = $discord->factory(Game::class, [\n 'name' => 'i am playing a game!',\n]);\n\n$discord->updatePresence($game);", "language": "php", "name": "Example" } ] } [/block] [block:api-header] { "type": "fn", "title": "joinVoiceChannel($channel, $mute, $deaf, $monolog)" } [/block] Attempts to connect to a voice channel. Returns a Promise with a [Voice Client](doc:voiceclient). [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "h-3": "Default", "0-0": "`$channel`", "0-1": "The Voice Channel to join.", "0-2": "[Channel](doc:channel)", "0-3": "-", "1-0": "`$mute`", "1-1": "Whether the client should be self-muted.", "1-2": "`bool`", "1-3": "`false`", "2-0": "`$deaf`", "2-1": "Whether the client should be self-deafened.", "2-2": "`bool`", "2-3": "`true`", "3-0": "`$monolog`", "3-1": "The Monolog logger to use.", "3-2": "`Monolog`", "3-3": "`null`" }, "cols": 4, "rows": 4 } [/block] [block:code] { "codes": [ { "code": "<?php\n\n$discord->joinVoiceChannel($channel)->then(function (VoiceClient $vc) {\n echo \"Joined voice channel.\\r\\n\";\n $vc->playFile('myfile.mp3');\n}, function ($e) {\n echo \"There was an error joining the voice channel: {$e->getMessage()}\\r\\n\"; \n});", "language": "php", "name": "Example" } ] } [/block] [block:api-header] { "type": "fn", "title": "getVoiceClient($id)" } [/block] Attempts to retrieve a voice client. Returns a Promise with a [Voice Client](doc:voiceclient) [block:parameters] { "data": { "h-0": "Name", "h-1": "Description", "h-2": "Type", "0-0": "`$id`", "0-1": "The channel ID to look for.", "0-2": "`snowflake`" }, "cols": 3, "rows": 1 } [/block]