Getting Started
$ 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();Last updated
Was this helpful?