We are developing a bot for R&D Project, that is made for turn-based games in discord.
- (Optional) Use a VPS to host the bot and database We assume you have python installed.
- (Optional) Create a virtual environment
- Change directory to the gamebot file and use
pip3 install -r requirements.txt
(Optionally inside the virtual environment). (Required) - Install MYSQL, in our case we have installed Ver 8.0.25 for Linux.
- Create a database like so:
- Now do the following commands:
USE yourdatabasename
andsource directorytogamebot/database/dbscripts/dbtables.sql
where you change 'directorytogamebot' to your directory to the gamebot and useexit
to close the MYSQL environment. - Now that you are done with setting up the database, edit
config.json
with your discord bot token and MYSQL user, password, host and the same yourdatabasename as previous steps. - (Run the virtual environment if you made one and) If everything went correctly, you should be able to run
python3 main.py
. (To run a command 'forever', usenohup python3 main.py &
on linux/vps server)
This will be a lot more complicated, so I will be giving a brief explanation how it should be done using our files? Install and enable apache2 and mod_wsgi and then change the apache DocumentRoot to the gamebot directory. And then configure the mod_wsgi If you know how to setup a virtual environment using mod_wsgi, which we weren't able to figure out you could use the same virtual environment as explained in how to setup the bot and the database.
Instead we didn't know how to do that, so we globally installed the packages. And changing the DocumentRoot directory did not work for us either, so we moved the FlaskApp folder to /var/www and added the config file and database folder at /var/www/FlaskApp. I think it was very unfortunate that we weren't able to keep everything in one project.
A pretty handy link on how to deploy a flask application https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
You could however easily open the website on the localhost without apache2 and mod_wsgi, by just running app.py. This does require the database to be set up though!