luigiMinardi / discord-bot-rpg-naming

My bot to rename my bros and play TTRPG

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disclaimer

This bot was made to help me and my friends have a little more imersion in our discord TTRPG games (and facilitate for the GM's to remember the players names).

If you want to implement it yourself I explain below how, this was made to work in a single server in a very simple way, the bot has the highest role of the server and is admin.
On discord developers website the Privileged Gateway Intents are all activated to prevent bugs.

Copy the .env.example file, rename it to .env and complete it with your informations.

How to use

Download code, then open it on your prefered IDE.
Then on your terminal:

Create venv

python3 -m venv .venv

Activate venv

mac/linux

source .venv/bin/activate

windows

.venv\Scripts\activate.bat

Install dependencies

pip install -r requirements.txt

Run the project

python3 main.py

Increasing players or adding more games

Adding new player

To add a new player create a new line on the member_dict_ids where the key is the name of the player and the value is the id of the player on discord.
Example:

member_dict_ids = {
    "PlayerName": 123456789101112,
    "OtherPlayerName": 121110987654321

Then you add the player to every game with his/her name. If the player don't play you can rename him/her as Unknown.
Example:

member_dict_names_chuchuco = {
    "PlayerName": "PlayerGameNickname",
    "OtherPlayerName": "Unknown"
member_dict_names_ded = {
    "PlayerName": "PlayerGameNickname",
    "OtherPlayerName": "OtherPlayerGameNickname"

Adding new game

To add a new game create a new dictionary of the new game, same as those shown above (member_dict_names_chuchuco and member_dict_names_ded).

@bot.command(pass_context=True)
async def game(ctx):
    for ids in member_dict_ids:
        guild = bot.get_guild(guild_id)
        member = guild.get_member(member_dict_ids[ids])
        await member.edit(nick=f"{member_dict_names_ded[ids]}")
        await ctx.send(f'Nickname was changed for {member.mention} ')

Remember, you need to edit the name of the function (what is after def and before (ctx)), in the example it's being called game.
This function name will be the command of the bot that you will call to change the nicknames (ih the eg. -game).
Since the function is the command name the name should not repeat.

Also in the third line of the for loop when you have the await member.edit you should change the member_dict_names_* to the dict with the names of your game.
In the example the game is D&D so we are using member_dict_names_ded, if we want to create a function to play chuchuco we should change to member_dict_names_chuchuco.

About

My bot to rename my bros and play TTRPG


Languages

Language:Python 100.0%