This project was made to make it easier to start a bot, without having the clogged index file with the ->on
function & other things.
<?php
require_once 'bootstrap.php';
use App\Application;
use Discord\WebSockets\Event;
use Discord\WebSockets\Intents;
/**
* @see https://discord.com/developers/docs/intro
*/
$app = new Application([
'token' => env('DISCORD_TOKEN'),
'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS,
'loadAllMembers' => true,
]);
$app->discord->run();
<?php
declare(strict_types=1);
namespace App\Events;
use App\EventAbstract;
use Discord\Discord;
use Discord\Parts\Channel\Message;
class MessageCreate extends EventAbstract
{
/**
* Logger instance
*
* @var Psr\Log\LoggerInterface
*/
protected $log;
/**
* Setup functions
* The name of this function is not required to be `setup`
* the only function names you cannot use are the ones inside EventAbstract::class
*
* @param Message $message Message event object
* @param Discord $discord Discord class
*
* @return void
*/
public function setUp(Message $message, Discord $discord)
{
$this->log = $discord->getLogger();
$this->log->info('Log stuff');
}
/**
* In this function, the event will terminate IF the function returns true
* if it doesn't return true, it will just keep going until there's no more functions in the class.
*
* @param Message $message Message event object
* @param Discord $discord Discord class
*
* @return true
*/
public function terminateExample($message, $discord)
{
$this->log->info('another example');
return true;
}
}
We are open to contributions.