valgorithms / pzbot
Valgorithm's offical Discord bot for Project Zomboid built in ReactPHP.
Requires
- php: ^8.0.0
- clue/redis-react: ^2.6
- react/async: 4.x-dev
- react/child-process: 0.6.4
- react/filesystem: ^0.2@dev
- team-reflex/discord-php: dev-master
- wyrihaximus/react-cache-redis: ^4.2.0
Suggests
- ext-event: For a faster, and more performant loop
- ext-libev: For a faster, and more performant loop
- ext-mbstring: For accurate calculations of string length when handling non-english characters.
- ext-uv: For a faster, and more performant loop. PHP >=7 only. Preferred.
- vzgcoders/twitchphp: For integration with Twitch chat.
This package is auto-updated.
Last update: 2024-10-17 17:52:41 UTC
README
This is a PZ BOT class for DiscordPHP. It provides functionalities for interacting with Discord using PHP.
Installation
Before you start, make sure you have PHP installed on your machine. This BOT class requires PHP CLI to run.
- Clone this repository to your local machine.
- Navigate to the project directory.
- Install the required dependencies. This project requires the
Monolog
library for logging and theBigInt
extension for big integer operations. If you're using Composer, you can install these dependencies by runningcomposer install
.
Usage
To use the PZ BOT class, you need to create an instance of the class and pass an options array to the constructor. The options array should include the following keys:
discordToken
: Your Discord bot token.clientId
: Your Discord client ID.clientSecret
: Your Discord client secret.guild_id
: The ID of the guild (server) that the bot is connected to.channel_ids
: An associative array mapping channel names to their IDs.role_ids
: An associative array mapping role names to their IDs.loop
: An instance of the ReactPHP event loop.discord
: An instance of the DiscordPHP client.rcon
: An instance of the RCON client.
Here's an example of how to use the PZ BOT class:
$options = [ 'discordToken' => 'your_discord_token', 'clientId' => 'your_client_id', 'clientSecret' => 'your_client_secret', 'guild_id' => 'your_guild_id', 'channel_ids' => [ 'pz-players' => 'channel_id', // Channel name will automatically update with the # of players // Add more channels as needed ], 'role_ids' => [ 'role_name' => 'role_id', // Add more roles as needed ], 'loop' => $loop, 'discord' => $discord, 'rcon' => $rcon, ]; $bot = new PZ\BOT($options); $bot->run();
Replace 'your_discord_token', 'your_client_id', 'your_client_secret', 'your_guild_id', 'channel_name', 'channel_id', 'role_name', 'role_id', $loop, $discord, and $rcon with your actual values. Also, you might need to adjust the installation and usage instructions based on your actual project setup and requirements.
Contributing
Contributions are welcome! Please submit a pull request with any enhancements, bug fixes, or other contributions.
License
This project is licensed under the MIT License. See the LICENSE file for more details.