Getting Started

To start the bot you need to start it using CLI (Command Line)

Once the bot is up and running, you can start using the APIs

You can also use the APIs outside of bot event listener , but it is recomended to first start the bot using CLI before consuming the APIs

If you want to integerate into a framework and communicate with bot you can implement something like Web Panel

See Example (Web Panel) (Supports both Send and Recieve)

Start the bot

$ php bot.php
<?php

require('vendor/autoload.php');

use \HobsRkm\SDK\PHPDiscordSDK\PHPDiscordSDKFactory;

class Bot {

    public function start() {
        PHPDiscordSDKFactory::getInstance()
            ->botConnect(<<<<BOT TOKEN>>>>>)
            ->then(
                function ($bot) {
                    $bot->on('message', function ($event) {
                        PHPDiscordSDKFactory::getInstance()
                        ->formatEvent($event)->then(function($message){
                        //Bot Event Listener
                        //call other APIs
                            print_r($message);//prints server details
                        }, function ($reason) {
                        //message event errors
                    });
                     $bot->on('close', function ($event) {
                       $this->start();
                    });
                });
            },
            function ($reason) {
            //other errors, bot startup, authentication
            }
        );
    }
}

$bot = new Bot();
$bot->start();

Visit https://github.com/hobsRKM/DiscordAPIWeb for all the APIs Demo

Try out all the APIs in real-time at https://discordapidemo.com

Last updated