https://github.com/loic-simon/pcmc-bot
Discord bot to manage and communicate a hosted Minecraft server
https://github.com/loic-simon/pcmc-bot
Last synced: 24 days ago
JSON representation
Discord bot to manage and communicate a hosted Minecraft server
- Host: GitHub
- URL: https://github.com/loic-simon/pcmc-bot
- Owner: loic-simon
- License: other
- Created: 2021-07-15T10:24:48.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-23T21:14:05.000Z (almost 4 years ago)
- Last Synced: 2025-02-17T07:31:06.594Z (4 months ago)
- Language: Python
- Size: 143 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pcmc-bot
Discord bot for managing and communicating with PC Minecraft server.
*Please not that this project's source code (comments, docstrings) is written
exclusively in French. The bot itself uses only French language; no
internationalization is available at this time.*## What's New in PCMC-Bot
Only major features are reported here; see [`CHANGELOG.md`](CHANGELOG.md)
or in [the doc](https://pcmc-bot.readthedocs.io/fr/2.1.4/changelog.html) for
details.### 1.0
* Communication with Minecraft server (status, commands)...
* In-game transmission of Discord messages & voice (dis)connections;## Installation
This project is (for now) meant for private usage and therefore not published
on PyPI. Clone this repository to use it:
```bash
git clone https://github.com/loic-simon/pcmc-bot.git
```We strongly recommand to install this package in a dedicated virtualenv
(`python3 -m venv `).### Dependencies
* Python 3.8+
* Packages: see [`requirements.txt`](requirements.txt)## Configuration
To run correctly, the bot needs to be connected to several external services,
each needing more or less sensitive tokens, stocked as environments variables.
We support and encourage the use of
[`python-dotenv`](https://pypi.org/project/python-dotenv/) to read them from
a `.env` file, but you may prefer exporting them as environment variables.All necessary variables, prefixed by `PCMC_`, are listed in
[`model.env`](model.env).## Usage
This package's external API consists essentially in a
[`discord.ext.commands.Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bot)
subclass, **`PCMCBot`**, which implements every features needed.The minimal code needed to run the bot in a configured folder is:
```py
from pcmc import PCMCBotbot = PCMCBot()
bot.run()
```### Bot usage
Once the bot connected to your Discord server, send `!help` to see every
available commands (note: some commands are only visible by specific roles;
grant yourself the "admin" role to see everything.) \
Use `!help command` to get more information about a command.### Customization
Since `PCMCBot` is a subclass of
[`discord.ext.commands.Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bot),
you can use every arguments and methods it supports or subclass it to override
existing behavior.We also provide a direct way to customize some parameters of the game and
of the Discord server through [`config`](pcmc/config.py) module:
roles/channels/emoji names, date of season beginning, inscription
customization... See
[the doc](https://pcmc-bot.readthedocs.io/fr/2.1.4/config.html)
for full API usage information.See additional attributes and overriden methods on
[the doc](https://pcmc-bot.readthedocs.io/) (mostly in French)Some useful examples:
#### Change command prefix
```py
from pcmc import PCMCBotbot = PCMCBot(command_prefix="?")
bot.run()
```#### Customize some config options
```py
from pcmc import PCMCBot, configconfig.Role.admin = "BOSS"
bot = PCMCBot()
bot.run()
```#### Delete a command or alias
```py
from pcmc import PCMCBotbot = PCMCBot()
bot.remove_command("command_name")
bot.run()
```#### Add a command or change the behavior of a command
```py
from discord.ext import commands
from pcmc import PCMCBot@commands.command()
async def mycommand(ctx, ...):
...bot = PCMCBot()
bot.remove_command("mycommand") # If replacing an existing command
bot.add_command(mycommand)
bot.run()
```#### Enhance or replace the reaction to a Discord event
```py
from pcmc import PCMCBotasync def say_hello(bot, member):
await member.send("Hey!")class MyBot(PCMCBot):
"""Your customized bot class"""
async def on_member_join(self, member):
await say_hello(self, member)
super().on_member_join(member) # Invoke the original reactionbot = MyBot()
bot.run()
```See [discord.py documentation](https://discordpy.readthedocs.io) for more
ideas.## Contributing
Community contributions are not welcome for now. Get in touch with the authors
(see below) for any question or suggestion about this project.## License
This work is shared under [the MIT license](LICENSE).© 2020 Loïc Simon – GRIs – ESPCI Paris - PSL.
Reach me on Discord:
[LaCarpe#1674](https://discordapp.com/users/264482202966818825) or by mail:
[[email protected]](mailto:[email protected])