2017 © Pedro Peláez
 

project discord-base-bot

image

lfgamers/discord-base-bot

  • Sunday, September 18, 2016
  • by aequasi
  • Repository
  • 1 Watchers
  • 2 Stars
  • 108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Discord Server List Bot

Welcome to the DiscordPHP based "BaseBot". This library is a foundation for your own PHP-Based Discord Bot. This library built on the Symfony 2 framework., (*1)

Requirements

  • PHP ^5.6|^7.0
  • Mysql OR Mongo
  • Composer
  • A Discord Bot Account (and its token)

Installation

This library can be installed with composer:, (*2)

composer require lfgamers/discord-base-bot

Usage

To get a super basic bot running, you will have to create a module, and your module will have to set up a Server class that extends Discord\Base\AppBundle\Model\Server, and then create a simple entry script like the following:, (*3)

<?php

use Discord\Base\Bot;

require __DIR__.'/../vendor/autoload.php';

$bot = Bot::create(
    [
        'modules'    => [
            MyModule::class
        ],
        'parameters' => [
            'name'        => 'MyFirstDiscordBot',
            'version'     => '0.0.1',
            'author'      => 'AwesomePerson',
            'log_dir'     => __DIR__.'/var/logs/',
            'cache_dir'   => __DIR__.'/var/cache/',
            'admin_id'    => 'MyDiscordUserAccountId',
            'token'       => 'MyBotToken',
            'prefix'      => '%',
            'status'      => 'with My Awesome Discord Bot',
            'server_class' => MyModule\Model\Server::class,
        ],
        'databases'  => [
            'mysql' => [
                'enabled' => true,
                'dsn'     => 'mysql://localhost/database',
            ],
        ],
    ]
);

$bot->run();

If you haven't run the bot before, you have to set up the schema with:, (*4)

php bot.php doctrine:schema:create, (*5)

Then, run that file with the arguments discord:run to start the bot., (*6)

Modules

To add your own commands and code, you will need to make your own Module (which is just an extension of Symfony's Bundle class), and then create BotCommand's that extend AbstractBotCommand., (*7)

Your directory structure should look something like (The directory for bot commands must be named "BotCommand", and commands must be suffixed with "BotCommand"):, (*8)

``` src BotCommand MyBotCommand.php MyModule.php ````, (*9)

The Versions