Discord PHP is a PHP library developed to include and simplify the creation and connection between websites, online applications and Discord.
Just PHP 5.6+ is required. Let's start downloading the discord-php library, then extract it to your_server_path/
.
Import the discord.php
file to any .php
file where you need to use the Discord PHP lib.
require_once("your_server_path/discord.php");
Before using the Discord PHP lib, You must create your Discord App, then configure the lib at discord-php/config.json
as following:
{
"client_id" : "YOUR_CLIENT_ID",
"client_secret" : "YOUR_CLIENT_SECRET",
"token" : "YOUR_BOT_TOKEN",
"assets" : [
"rich_assets_name_1",
"rich_assets_name_2"
],
"run_bot" : false
}
Where:
client_id
=@me
- Required for oAuth2 / Token Exchange requests;;client_secret
= Required for oAuth2 / Token Exchange requests;token
= Required for any API Request such as$discord->users->get();
;run_bot
= Settrue
if you are running this library asPHP CLI
looking to create your own Bot using .php (It cannot be used on a WebServer)
All of these will be added to $discord->config
. If You need to modify client_id
, client_secret
and/or token
dynamically, You can change it as shown below:
// Modify Client ID
$discord->config->client_id = "YOUR_NEW_CLIENT_ID";
// Modify Client Secret
$discord->config->client_secret = "YOUR_NEW_CLIENT_SECRET";
// Modify Bot Token
$discord->config->token = "YOUR_NEW_BOT_TOKEN";
You are now ready to use the Discord PHP lib as you wish! Everything you need to know about the library, such as Classes and "How To Use", is described here in the Wiki. I hope this library will help you coding for Discord in PHP. Any suggestion or improvement is always welcome.
If you are looking to create your own bot, coding in PHP and using this lib, please click here to know more.
- Discord Hack Week update
- Added
$discord->games
functions - Added
Discord Invaders
game - Launch games (for WebHosting only)
- Added
$discord->webhooks
functions (check the wiki to know more) - Added
429 too many requests
handler - Added medias used on GitHub Documentation
- Updated
$discord->requests->requestor
- Fixed some syntax errors
- Added
$discord->gateway->get
- Added
$discord->gateway->getBot
- Added
$discord->gateway->client
(if$discord->config->run_bot
=true
) - Added custom code
- Added WebSocket implementation (Based on @ratchetphp)
- Added Bot feature + vendor.zip (Based on @teamreflex/DiscordPHP)
- Updated
$discord->keys
- Fixed some syntax errors
- Fixed some wrong paths
- Added
$discord->users->dms
by token - Added
$discord->users->get
by token - Added
$discord->users->guilds
by token - Added
$discord->requests->custom
function for custom requests - Fixed missing global var
- Fixed missing oAuth path key
- Fixed few syntax parts
- Examples are now here to help you coding
- First release of discord-php lib