Skip to content

psecio/dbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBot: A Discord bot in PHP

The DBot library provides a long-running bot process written in PHP.

Installation

git clone [email protected]:psecio/dbot.git
composer install

Copy the .env.dist file to .env and configure it with your bot's token.

Usage

php bin/dbot.php

Adding a Dispatch action

When the Discord API sends a new event on the websocket, your bot will receive the message with a t value in the JSON. This is the "dispatch type". Handlers for these can be added to the bin/dbot.php script like this for a GUILD_CREATE:

<?php
$bot = new Bot($_ENV['BOT_TOKEN']);

$bot->addDispatch('GUILD_CREATE', function($json) {
    echo 'guild create!!!!'."\n";

    return 'test';
});

$bot->init();
?>

Releases

No releases published

Packages

No packages published

Languages