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.
Only major features are reported here; see CHANGELOG.md
or in the doc for
details.
- Communication with Minecraft server (status, commands)...
- In-game transmission of Discord messages & voice (dis)connections;
This project is (for now) meant for private usage and therefore not published on PyPI. Clone this repository to use it:
git clone https://github.com/loic-simon/pcmc-bot.git
We strongly recommand to install this package in a dedicated virtualenv
(python3 -m venv <yourfolder>
).
- Python 3.8+
- Packages: see
requirements.txt
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
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
.
This package's external API consists essentially in a
discord.ext.commands.Bot
subclass, PCMCBot
, which implements every features needed.
The minimal code needed to run the bot in a configured folder is:
from pcmc import PCMCBot
bot = PCMCBot()
bot.run()
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.
Since PCMCBot
is a subclass of
discord.ext.commands.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
module:
roles/channels/emoji names, date of season beginning, inscription
customization... See
the doc
for full API usage information.
See additional attributes and overriden methods on the doc (mostly in French)
Some useful examples:
from pcmc import PCMCBot
bot = PCMCBot(command_prefix="?")
bot.run()
from pcmc import PCMCBot, config
config.Role.admin = "BOSS"
bot = PCMCBot()
bot.run()
from pcmc import PCMCBot
bot = PCMCBot()
bot.remove_command("command_name")
bot.run()
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()
from pcmc import PCMCBot
async 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 reaction
bot = MyBot()
bot.run()
See discord.py documentation for more ideas.
Community contributions are not welcome for now. Get in touch with the authors (see below) for any question or suggestion about this project.
This work is shared under the MIT license.
© 2020 Loïc Simon – GRIs – ESPCI Paris - PSL.
Reach me on Discord: LaCarpe#1674 or by mail: loic.simon@espci.org