PHPackages                             robotic-passion/livia - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. robotic-passion/livia

ActiveLibrary[Framework](/categories/framework)

robotic-passion/livia
=====================

Livia is a Discord Bot framework for PHP.

0.1.0(5y ago)01Apache-2.0PHPPHP &gt;=7.1

Since May 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/RRWITP/livia)[ Packagist](https://packagist.org/packages/robotic-passion/livia)[ RSS](/packages/robotic-passion-livia/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Livia [![Build Status](https://camo.githubusercontent.com/64008a3c1fd205b62d92e94acadbdb1ea0f1182d00066dc6ef9024ab84f154f4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436861726c6f74746544756e6f69732f4c697669612f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/CharlotteDunois/Livia/build-status/master)
=============================================================================================================================================================================================================================================================================================================================================================

[](#livia-)

Livia is a Discord Bot framework, which utilizes [Yasmin](https://github.com/CharlotteDunois/Yasmin), the Discord API library.

Commando was used as template for the design of Livia.

Getting Started
===============

[](#getting-started)

Use [composer](https://packagist.org/packages/charlottedunois/livia) to install Livia and its dependencies.

```
composer require charlottedunois/livia

```

Built-in Argument Types
=======================

[](#built-in-argument-types)

Livia ships with a few argument types you can use for your command arguments. Here's a list:

- boolean
- channel
- command
- command-or-group
- float
- group
- integer
- member
- role
- string
- user

Built-in Commands
=================

[](#built-in-commands)

The following commands are coming with Livia:

- disable (disable commands/groups)
- enable (enable commands/groups)
- load (load new commands)
- reload (reload command(s))
- unload (unload a command)
- eval (evaluates PHP code)
    - All PHP errors get thrown.
    - Defines randomized eval namespace for eval execution.
    - It has an anonymous function called `$doCallback`, which takes whatever value you give, inspects it and sends it as reply to Discord.
    - The client is exposed through `$this->client` and `$client`.
    - You have access to the specific `CommandMessage` instance through `$message`.
    - The last eval result is accessible through `$this->lastResult`.
- help (displays a help message in DM)
- ping (calculates the bot's latency)
- prefix (gets or sets the bot's prefix in the guild/globally)

Setting Provider
================

[](#setting-provider)

A Setting Provider sits as middle-man between Livia and the DBMS. The job of the Setting Provider is to permanently store the settings, such as guild prefixes.

There are two providers included in Livia:

#### MySQL/MariaDB (react/mysql)

[](#mysqlmariadb-reactmysql)

`MySQLProvider` - a provider for MySQL/MariaDB, which utilizes [`react/mysql`](https://github.com/friends-of-reactphp/mysql).

Usage:

```
$factory = new \React\MySQL\Factory($your_livia_client->getLoop());
$factory->createConnection('user:password@localhost/database')->done(function (\React\MySQL\ConnectionInterface $db) use ($your_livia_client) {
    $provider = new \CharlotteDunois\Livia\Providers\MySQLProvider($db);
    $your_livia_client->setProvider($provider);
});
```

#### Plasma

[](#plasma)

`PlasmaProvider` - a provider for Plasma [`plasma/plasma`](https://github.com/PlasmaPHP/plasma).

Plasma is a non-blocking, asychronous data-access database abstraction layer. To use plasma you also need a driver, which communicates with the database server.
For MySQL/MariaDB there is [`plasma/driver-mysql`](https://github.com/PlasmaPHP/driver-mysql), which supports Prepared Statements.

Usage:

```
// See the plasma project for how to create a plasma client

$provider = new \CharlotteDunois\Livia\Providers\PlasmaProvider($plasma_client);
$your_livia_client->setProvider($provider);
```

Making Commands
===============

[](#making-commands)

Livia features Commands Reloading, which requires you to return an anonymous function in your command file, which returns a new anonymous class.

Do not declare functions outside of the class. This will turn into a **Fatal Error** as the function can not be re-declared.
Other restrictions apply as well. If you need any (helper) functions or constants, declare them inside the class as method or class constant.

Example:

```
// /rootBot/commands/moderation/ban.php

// Livia forces you to use lowercase command name and group ID.
// (moderation = group ID, ban = command name)

// Livia will automatically call the anonymous function and pass the LiviaClient instance.
return function ($client) {
    // Extending is required
    return (new class($client) extends \CharlotteDunois\Livia\Commands\Command {
        function __construct(\CharlotteDunois\Livia\Client $client) {
            parent::__construct($client, array(
                'name' => 'ban',
                'aliases' => array(),
                'group' => 'moderation',
                'description' => 'Bans an user.',
                'guildOnly' => true,
                'throttling' => array( // Throttling is per-user
                    'usages' => 2,
                    'duration' => 3
                ),
                'args' => array(
                    array(
                        'key' => 'user',
                        'prompt' => 'Which user do you wanna ban?',
                        'type' => 'member'
                    )
                )
            ));
        }

        // Checks if the command is allowed to run - the default method from Command class also checks userPermissions.
        // Even if you don't use all arguments, you are forced to match that method signature.
        function hasPermission(\CharlotteDunois\Livia\Commands\Context $context, bool $ownerOverride = true) {
            return $context->message->member->roles->has('SERVER_STAFF_ROLE_ID');
        }

        // Even if you don't use all arguments, you are forced to match that method signature.
        function run(\CharlotteDunois\Livia\Commands\Context $context, \ArrayObject $args,
                      bool $fromPattern) {
            // Do what the command has to do.
            // You are free to return a Promise, or do all-synchronous tasks synchronously.

            // If you send any messages (doesn't matter how many),
            // return (resolve) the Message instance, or an array of Message instances.
            // Promises are getting automatically resolved.

            return $args->user->ban()->then(function () use ($context) {
                return $context->reply('The user got banned!');
            });
        }
    });
};
```

Example
=======

[](#example)

```
require_once(__DIR__.'/vendor/autoload.php');

$loop = \React\EventLoop\Factory::create();
$client = new \CharlotteDunois\Livia\Client(array(
    'owners' => array('YOUR_USER_ID'),
    'unknownCommandResponse' => false
), $loop);

// Registers default commands, command groups and argument types
$client->registry->registerDefaults();

// Register the command group for our example command
$client->registry->registerGroup(array('id' => 'moderation', 'name' => 'Moderation'));

// Register our commands (this is an example path)
$client->registry->registerCommandsIn(__DIR__.'/commands/');

// If you have created a command, like the example above, you now have registered the command.

$client->on('ready', function () use ($client) {
    echo 'Logged in as '.$client->user->tag.' created on '.
           $client->user->createdAt->format('d.m.Y H:i:s').PHP_EOL;
});

$client->login('YOUR_TOKEN')->done();
$loop->run();
```

Documentation
=============

[](#documentation)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2179d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5157609?v=4)[Tim Joosten](/maintainers/Tjoosten)[@Tjoosten](https://github.com/Tjoosten)

---

Top Contributors

[![Tjoosten](https://avatars.githubusercontent.com/u/5157609?v=4)](https://github.com/Tjoosten "Tjoosten (1 commits)")

### Embed Badge

![Health badge](/badges/robotic-passion-livia/health.svg)

```
[![Health](https://phpackages.com/badges/robotic-passion-livia/health.svg)](https://phpackages.com/packages/robotic-passion-livia)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[laravel/tinker

Powerful REPL for the Laravel framework.

7.4k423.8M1.8k](/packages/laravel-tinker)[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
