2017 © Pedro Peláez
 

library discord-php

An unofficial API to interact with the voice and text service Discord.

image

team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

  • Sunday, September 3, 2017
  • by uniquoooo
  • Repository
  • 25 Watchers
  • 213 Stars
  • 18,974 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 94 Forks
  • 71 Open issues
  • 28 Versions
  • 3 % Grown

The README.md

DiscordPHP

Latest Stable Version Latest Unstable Version Total Downloads PHP Version Require, (*1)

PHP Discorders, (*2)

A wrapper for the official Discord REST, gateway and voice APIs. Documentation is available here, albeit limited at the moment, as well as a class reference. Feel free to ask questions in the Discord server above., (*3)

For testing and stability it would be greatly appreciated if you were able to add our test bot to your server. We don't store any data - the bot simply idles and does not interact with anyone and is used to test stability with large numbers of guilds. You can invite the bot here., (*4)

Cache Interface (experimental)

Warning This branch contains an experimental feature, do not use it in production! See the wiki page for more information on how to set it up., (*5)

FAQ

  1. 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.
  2. PHP is running out of memory?
    • Try unlimit your PHP memory using ini_set('memory_limit', '-1');.

Getting Started

Before you start using this Library, you need to know how PHP works, you need to know how Event Loops and Promises work. This is a fundamental requirement before you start. Without this knowledge, you will only suffer., (*6)

Requirements

  • One of ext-uv (recommended), ext-ev or ext-event for a faster, and more performant event loop.
  • ext-mbstring if handling non-latin characters.

Voice Requirements

Windows and SSL

Unfortunately PHP on Windows does not have access to the Windows Certificate Store. This is an issue because TLS gets used and as such certificate verification gets applied (turning this off is not an option)., (*7)

You will notice this issue by your script exiting immediately after one loop turn without any errors., (*8)

As such users of this library need to download a Certificate Authority extract from the cURL website.
The path to the caextract must be set in the php.ini for openssl.cafile., (*9)

Installing DiscordPHP

DiscordPHP is installed using Composer., (*10)

  1. Run composer require team-reflex/discord-php. This will install the latest stable release.
    • If you would like, you can also install the development branch by running composer require team-reflex/discord-php dev-master.
  2. Include the Composer autoload file at the top of your main file:
    • include __DIR__.'/vendor/autoload.php';
  3. Make a bot!

Basic Example

<?php

include __DIR__.'/vendor/autoload.php';

use Discord\Discord;
use Discord\Parts\Channel\Message;
use Discord\WebSockets\Intents;
use Discord\WebSockets\Event;

$discord = new Discord([
    'token' => 'bot-token',
    'intents' => Intents::getDefaultIntents()
//      | Intents::MESSAGE_CONTENT, // Note: MESSAGE_CONTENT is privileged, see https://dis.gd/mcfaq
]);

$discord->on('ready', function (Discord $discord) {
    echo "Bot is ready!", PHP_EOL;

    // Listen for messages.
    $discord->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
        echo "{$message->author->username}: {$message->content}", PHP_EOL;
        // Note: MESSAGE_CONTENT intent must be enabled to get the content if the bot is not mentioned/DMed.
    });
});

$discord->run();

See examples folder for more., (*11)

Documentation

Documentation for the latest version can be found here. Community contributed tutorials can be found on the wiki., (*12)

Contributing

We are open to contributions. However, please make sure you follow our coding standards (PSR-4 autoloading and custom styling). Please run php-cs-fixer before opening a pull request by running composer run-script cs., (*13)

License

MIT License, © David Cole and other contributers 2016-present., (*14)

The Versions

16/04 2016
09/04 2016

dev-user-accounts

dev-user-accounts

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

09/04 2016

v3.2.0

3.2.0.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

21/02 2016

v3.1.2

3.1.2.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

15/02 2016

v3.1.1

3.1.1.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

12/02 2016

v3.1.0

3.1.0.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

17/01 2016

v3.0.3

3.0.3.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/01 2016

v2.1.3

2.1.3.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/01 2016

v3.0.2

3.0.2.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/01 2016

v2.1.2

2.1.2.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/01 2016

v3.0.1

3.0.1.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/01 2016

v2.1.1

2.1.1.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

08/01 2016

v3.0.0

3.0.0.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

05/01 2016

v2.1.0

2.1.0.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

21/12 2015

v2.0.1

2.0.1.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

18/12 2015

v2.0.0

2.0.0.0

An unofficial API to interact with the voice and text service Discord.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

13/08 2015

v1.0.0

1.0.0.0

An API to interface with Discord

  Sources   Download

The Requires

 

by David Cole