-
Notifications
You must be signed in to change notification settings - Fork 148
Installing Ballsdex
You need to install Docker and git on your computer.
When installing git, be sure to choose the option that says "Git from the command line and also for 3rd-party software". Leave the other options to their default values.
If you cannot install Docker, keep reading, you can run the bot without it but it's not recommended.
You must first setup a Discord bot account. You can follow discord.py's tutorial to create and invite your bot.
For now, don't copy your token, but keep the page open.
Once this is configured, you also need to enable message content intent. Go to the "Bot" tab of your application, scroll down to "Privileged intents" and tick "Message content".
Tip: You can fill the description of your application, it will appear under the "About me" section.
-
Right-click in the place where you want to install the bot, for instance your desktop, and select "Git bash here".
-
Paste the following command:
git clone https://github.com/laggron42/BallsDex-DiscordBot.git
A folder named BallsDex-DiscordBot
should have appeared. If not, right-click and hit "Refresh".
-
Open the terminal app and navigate to the folder where you want to install the bot using the
cd
command. For instance, if you want to install the bot in your desktop, typecd Desktop
. -
Paste the following command:
git clone https://github.com/laggron42/BallsDex-DiscordBot.git
A folder named BallsDex-DiscordBot
should have appeared.
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Make sure the bot is running by entering the
docker ps
command. If there is an error such as "Cannot connect to the Docker daemon", start Docker. - Run
docker compose build
. This will download a lot of components and may take some time, wait until it is done.
- Install PostgreSQL and turn the server on.
- Install Redis server and turn it on.
- Install poetry
- Install Python 3.10 at least
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Run
poetry install
We will need to run the bot at least once to make the bot create the configuration file template.
-
Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
-
Type
docker compose build
. This will take a while -
Type
docker compose up bot
. This may also take a while the first time. -
Wait for the bot to start until this appears
-
Exit by hitting
Ctrl+C
-
Make sure the bot is fully shut down by typing
docker compose down
Open the config.yml
file with the editor of your choice. Notepad and TextEdit are good enough native solutions.
Note: In YAML files, everything after a # is a comment. Those lines are here to document and help you understand the possible values.
-
Go back to the Discord developer portal and click "Reset Token" to obtain a new one. Copy and paste it right after
discord-token:
. Make sure that there is a space betweendiscord-token:
and your token, otherwise it will not work.Warning: Do not share your token! It is the password of your bot, and allows anyone full access to its account if shared. Be sure to keep it secure, and immediately reset if you think it leaked.
-
The
about
section defines a few traits of the/about
command. Feel free to change thedescription
and thediscord-invite
. -
You can change
collectible-name
which will replace the wordcountryball
in the bot. For instance if you set "rock", the bot will say "A wild rock spawned!" -
bot-name
is used in various places like/about
or/balls completion
. -
The
admin
section configures the/admin
command. This command is only enabled in specific servers for specific roles.-
guild-ids
is for the servers where you want to enable the/admin
command. Copy the IDs of the servers you want, and paste them -
root-role-ids
is for the roles IDs which will get full access to the/admin
command, granting the ability to spawn or give balls and control blacklist. -
admin-role-ids
is for the role IDs which will get partial access to the/admin
command. Their access will be limited to blacklist control and seeing shared servers.
General notice about IDs
To obtain an ID, enable developer mode and right click a server or a role, then select "Copy ID".
If you have just one ID, put it like this (for instance guild IDs)
guild-ids: - 1049118743101452329
If you have multiple IDs, they should be placed like this (for instance role IDs here):
root-role-ids: - 1049119446372986921 - 1049119786988212296
-
Unless you know about Prometheus and Grafana, you can leave the other stuff as they are.
Here's the config.yml
file from Ballsdex if you want to compare and troubleshoot eventual issues:
# paste the bot token after regenerating it here
discord-token: INSERT_TOKEN_HERE
# prefix for old-style text commands, mostly unused
text-prefix: b.
# define the elements given with the /about command
about:
# define the beginning of the description of /about
# the other parts is automatically generated
description: >
Collect countryballs on Discord, exchange them and battle with friends!
# override this if you have a fork
github-link: https://github.com/laggron42/BallsDex-DiscordBot
# valid invite for a Discord server
discord-invite: https://discord.gg/ballsdex # BallsDex official server
terms-of-service: https://gist.github.com/laggron42/52ae099c55c6ee1320a260b0a3ecac4e
privacy-policy: https://gist.github.com/laggron42/1eaa122013120cdfcc6d27f9485fe0bf
# WORK IN PROGRESS, DOES NOT FULLY WORK
# override the name "countryballs" in the bot
collectible-name: countryball
# WORK IN PROGRESS, DOES NOT FULLY WORK
# override the name "BallsDex" in the bot
bot-name: BallsDex
# players group cog command name
# this is /balls by default, but you can change it for /animals or /rocks for example
players-group-cog-name: balls
# enables the /admin command
admin-command:
# all items here are list of IDs. example on how to write IDs in a list:
# guild-ids:
# - 1049118743101452329
# - 1078701108500897923
# list of guild IDs where /admin should be registered
guild-ids:
- 1049118743101452329
# list of role IDs having full access to /admin
root-role-ids:
- 1049119446372986921
- 1049119786988212296
# list of role IDs having partial access to /admin
admin-role-ids:
- 1073775485840003102
- 1073776116898218036
# prometheus metrics collection, leave disabled if you don't know what this is
prometheus:
enabled: true
host: "0.0.0.0"
port: 15260
Now we should be ready for the next part.
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Run
docker compose up
. This will start all services and show the logs live in the console. If you close the console, the bot will be shut down.- If you run
docker compose up -d
, you will be running in detached mode. You can close the window safely, and the bot will continue running. You can usedocker compose logs -f
to view the logs.
- If you run
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Type
docker compose down
and wait for all services to go down. - If you're restarting, simply type
docker compose up
again. Do not usedocker compose restart
as it does not reload some elements.
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Run
poetry shell
- Export the
BALLSDEXBOT_DB_URL
environment var so that it points to your PostgreSQL server (for instancepostgres://ballsdex:password@localhost:5432/ballsdex
) - Export the
BALLSDEXBOT_REDIS_URL
environment var so that it points to your Redis server (for instanceredis://127.0.0.1
) - Export the environment vars defined in the
.env
file. Do it manually or check this post. - Start the bot with
python3 -m ballsdex
.- You can look for additional starting options by running
python3 -m ballsdex -h
, there's a full CLI available!
- You can look for additional starting options by running
- Start the admin panel with
python3 -m uvicorn ballsdex.core.admin:_app
Just hit Ctrl+C
.
Note: this only works for git installs. If you installed using a downloaded zip file, migrate to a git install now.
- Open a command prompt and navigate to the bot's folder
- Windows: Open the folder, then in the explorer's navigation bar, write "powershell"
-
macOS/Linux: Open the terminal and use
cd <folder>
to navigate (for instancecd Desktop/BallsDex-DiscordBot
)
- Run
git pull
and wait for the changes to be pulled.- If you encounter an error, which may happen when you're editing the source files, run
git reset --hard HEAD
to reset all changes done, then rungit pull again
- Note, if you do run
git reset
- it will reset any changes you may have. Be cautious of this.
- If you encounter an error, which may happen when you're editing the source files, run
Next, build the bot and restart it following your case:
- Build the code with
docker compose build
- Reboot with
docker compose down
thendocker compose up
- Check for new requirements by running
poetry install
- Shut down the bot with Ctrl+C, and restart the same way as usual
Support my work on Patreon and get exclusive rewards!
For $10/month, I will be hosting your custom bot on my server, with immediate updates, secure and shared admin panel, and stats on https://grafana.laggron.red !