The official PS13 Discord bot built on DiscordPHP with documentation available here, albeit limited at the moment, as well as a class reference. Feel free to ask questions in the Discord server above.
Before you start using this Library, you need to know how PHP works, you need to know the language and you need to know how Event Loops and Promises work. This is a fundamental requirement before you start. Without this knowledge, you will only suffer.
- Can I run PS13-Bot on a webserver (e.g. Apache, nginx)?
- No, PS13-Bot will only run in CLI. If you want to have an interface for your bot you can integrate react/http with your bot and run it through CLI.
- PHP 7.4
- We recommend PHP 8.0 as it will be the most stable and most performant.
- x86 (32-bit) PHP requires
ext-gmp
extension enabled for handling Permissions.
- Composer
ext-json
ext-zlib
Unfortunately PHP on Windows does not have access to the Windows Certificate Store. This is an issue because TLS gets used and as such certificate verification gets applied (turning this off is not an option).
You will notice this issue by your script exiting immediately after one loop turn without any errors. Unfortunately there is for some reason no error or exception.
As such users of this library need to download a Certificate Authority extract from the cURL website.
The path to the caextract must be set in the php.ini
for openssl.cafile
.
- The latest PHP version.
- One of
ext-uv
(recommended),ext-libev
orext-event
for a faster, and more performant event loop. ext-mbstring
if handling non-english characters.ext-gmp
if using 32-bit PHP.
- 64-bit Linux or Darwin based OS.
- If you are running on Windows, you must be using PHP 8.0.
ext-sodium
- FFmpeg
The PS13 class intends to streamline the development process when using the DiscordPHP and other libraries while simultaneously avoiding bloating the main bot.php file with a bunch of function definitions. It accomplishes this by defining functions as variables and passing them into the construction method at runtime via the declaration of an $options array. Functions are to be declared either according to the DiscordPHP event they should execute and in the order they should be executed or as a miscellaneous function that can simply be stored and referenced later.
$options = array();
$options['functions'] = [
'ready' => [ //Called automatically at start-up (Discord 'ready' event)
'on_ready' => $on_ready,
'status_changer_timer' => $status_changer_timer,
'status_changer_random' => $status_changer_random, //$status_changer_random = $PS13->functions->['ready']['status_changer_random']
],
'message' => [ //Called automatically whenever the bot sees a new message (Discord 'message' event)
'on_message' => $on_message,
'on_message2' => $on_message2,
],
'misc' => [ //Custom functions, can be called by other functions or externally
'recalculate_ranking' => $recalculate_ranking,
'ooc_relay' => $ooc_relay,
'timer_function' => $timer_function,
'status_changer' => $status_changer, //$status_changer = $PS13->functions->['misc']['status_changer']
],
];
See variable_functions.php for function examples.
We are open to contributions, just open a pull request and we will review it.
MIT License, © Valithor Obsidion and other contributers 2022-present.