sunxyw / discord-php
Requires
- php: ^5.6|^7.0
- cache/array-adapter: ^0.4.0
- guzzlehttp/guzzle: ~5.3|~6.0
- illuminate/support: ^4.0|^5.0
- monolog/monolog: ^1.19
- nesbot/carbon: ^1.18
- ratchet/pawl: 0.2.*
- react/datagram: 1.1.*
- react/partial: ^2.0
- react/socket-client: 0.4.*
- symfony/options-resolver: ^2.7|^3.0
- trafficcophp/bytebuffer: ^0.3
- wyrihaximus/react-guzzle-psr7: ^1.0
Requires (Dev)
- symfony/var-dumper: ^2.7|^3.0
Suggests
- ext-event: For a faster, and more performant loop
- ext-libev: For a faster, and more performant loop
- ext-libevent: For a faster, and more performant loop. Preferred
- cache/apc-adapter: Required to use the APC cache driver
- cache/memcache-adapter: Required to use the Memcache cache driver
- cache/memcached-adapter: Required to use the Memcached cache driver
- cache/redis-adapter: Required to use the Redis cache driver
README
Library is currently dead, doubt it works at all and if it does there are so many bugs that it needs another rewrite which I'm not wanting to do really, sorry. The fact that we even made a PHP library that interacts with the Discord gateway is kind of a miracle but it is time to say farewell. Thanks to everyone that helped out along the way, especially Aaron (@aequasi). Maybe one day someone can take over and do a rewrite. Much love,
- David
DiscordPHP
A wrapper for the official Discord REST, gateway and voice APIs.
FAQ
- Can I run DiscordPHP on a webserver (e.g. Apache, nginx)?
- No, DiscordPHP will only run in CLI. If you want to have an interface for your bot you can integrate react/http with your bot and run it through CLI.
Getting Started
Installing DiscordPHP
DiscordPHP 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.5.9, however it is reccomended that you use PHP 7. PHP 5.x support will be removed in the future.
This library has not been tested with HHVM.
- Run
composer require team-reflex/discord-php
. This will install the lastest release.- If you would like, you can also install the development branch by running
composer require team-reflex/discord-php dev-develop
.
- If you would like, you can also install the development branch by running
- Include the Composer autoload file at the top of your main file:
include __DIR__.'/vendor/autoload.php';
- Make a bot!
Basic Example
<?php include __DIR__.'/vendor/autoload.php'; use Discord\Discord; $discord = new Discord([ 'token' => 'bot-token', ]); $discord->on('ready', function ($discord) { echo "Bot is ready!", PHP_EOL; // Listen for messages. $discord->on('message', function ($message, $discord) { echo "{$message->author->username}: {$message->content}",PHP_EOL; }); }); $discord->run();
Notes
- This library can use a lot of RAM and PHP may hit the memory limit. To increase the memory limit, use
ini_set('memory_limit', '200M')
to increase it to 200 mb. If you would like it to be unlimited, useini_set('memory_limit', '-1')
.
Documentation
Raw documentation can be found in-line in the code and on the DiscordPHP Class Reference. More user friendly and examples will soon be coming on the DiscordPHP Wiki.
Contributing
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. Our StyleCI settings can be found here.
Library Comparison
See this chart for a feature comparison and list of other Discord API libraries.