Skip to content

Installation

FWidm edited this page May 22, 2022 · 8 revisions

Setup

Docker

The recommended setup is using docker:

  1. Install docker & docker-compose
  2. Clone the repository
  3. Go to the instance folder and copy config.example.py and paste it as config.py in the same folder.
  4. Open config.py, create a token as described in https://www.writebots.com/discord-bot-token/ and enter it:
...
# expected format: `token = 'supersecrettoken'`
token = 'supersecrettoken'
...
  1. Run docker-compose up (you can detach via -d argument)
  2. Verify that the docker container is running via docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
63198779dcf7        poediscordbot_bot   "pypy3 main.py"     7 minutes ago       Up 6 minutes                            pobdiscord
  1. Finished, your bot should be online and ready to go. Feel free to checkout the config file and adapt it to your needs. Afterwards you will have to rebuild with docker-compose up --build.

Obtaining logs

  • Simply view log content:
> docker exec -it pobdiscord cat discord_pob.log
2019-12-03 - 17:37:40 discord_pob  INFO     Starting pob discord bot...
2019-12-03 - 17:37:43 discord_pob  INFO     Logged in: uname=pob-discord, id=418777295713730570
  • Follow the logs with docker exec -it pobdiscord tail -f discord_pob.log
  • Copy logs with docker cp pobdiscord:/app/discord_pob.log discord_pob.log

Classic Setup

  1. Install Python 3.7+ & Pip3 (python3.7 -m pip install -r requirements.txt)
  2. go to the bot directory and install requirements: pip3 install -r requirements.txt
  3. see step 3. & 4. above
  4. python3.7 main.py
  5. bot should start up

Optional use of supervisord

  1. install via package manager
  2. add custom entry sudo vi /etc/supervisor/conf.d/discord-pob.conf, for me it was:
[program:discord-pob]
command=python3.7 main.py
directory=/home/anon/poediscordbot/
priority=900
user=anon
autostart=true
autorestart=true
  1. supervisorctl reread
  2. supervisorctl update
  3. Log is in the application directory under discord_pob.log

Known Issues / FAQ

Bot does start up but says: ImportError: cannot import name 'config'

Make sure you put the config.py file in the instance folder, the folder should look like this:

$ ll poediscordbot/instance/
total 20
drwxr-xr-x 3 pi pi 4096 May 22 11:05 ./
drwxr-xr-x 8 pi pi 4096 May 22 12:10 ../
-rw-r--r-- 1 pi pi 1237 May 22 10:50 config.example.py
-rw-r--r-- 1 pi pi 1294 May 22 10:52 config.py
drwxr-xr-x 2 pi pi 4096 May 22 11:05 __pycache__/

I Changed the config but nothing happens (in docker)

Make sure to rebuild the docker container docker-compose up --build or docker-compose down followed by docker-compose up