This is a PHP library for the Discord API. This library is limited to the basic REST api that Discord provides. If you are doing anything heavy, or fancy, you should probably look at the other php library.
./extra/gateway.html
in your browser.RestCord is installed using Composer. Make sure you have installed Composer and are used to how it operates. We require a minimum PHP version of PHP 5.4.0, however it is recommended that you use at least PHP 7.0. PHP 5 will be deprecated soon. This library REQUIRES 64bit PHP.
This library has not been tested with HHVM.
composer require restcord/restcord
. This will install the lastest release.
composer require restcord/restcord dev-master
.include __DIR__.'/vendor/autoload.php';
There's an example below, and more listed in the menu to the left. The RestCord\DiscordClient
is broken out into
categories just like the api itself: channel, gateway, guild, invite, oauth2, user, voice, and webhook.
You can view the methods of each of these categories by selecting the menu items on the left.
<?php
include __DIR__.'/vendor/autoload.php';
use RestCord\DiscordClient;
$discord = new DiscordClient(['token' => 'bot-token']); // Token is required
var_dump($discord->guild->getGuild(['guild.id' => 81384788765712384]));
Below is a table of the options available to the discord client
Name | Type | Required | Default | Description |
---|---|---|---|---|
token | string | Yes | ~ | Your bot token |
version | string | No | 1.0.0 |
The version of the API to use. Should probably be left alone |
logger | Monolog\Logger | false | new Logger('Logger') |
An instance of a Monolog\Logger |
throwOnRatelimit | bool | false | false |
Whether or not an exception is thrown when a ratelimit is supposed to hit |
apiUrl | string | false | https://discordapp.com/api/v6 |
Should leave this alone. |
tokenType | string | false | Bot |
Either Bot or OAuth |
API Documentation can be found in the menu to the left
We are open to contributions. However, please make sure you follow our coding standards (PSR-4 autoloading and custom styling). We use StyleCI to format our code. Contributing is a little strange with this library. We use a service definition generator to create a service description for guzzle. All of the logic in this repo is built off of the service description in the src/Resources directory.
To build a new service definition, just run:
$ ./bin/downloadServiceDefinition <version number>
To build new docs, run:
$ ./bin/buildDocs <version number>
Yes, I stole some of my docs from DiscordPHP