- Clone the repo in a directory of your choosing.
- Run the following commands to create virtual environment
python3 -m venv .venv
- Run the following commands to install the required libraries
.venv/bin/pip3 install -r requirements.txt
- Make a file named
.env
- Paste this line into
.env
and insert your discord bot token:DISCORD_TOKEN = "your token here"
- Run the following commands to run the bot using the virtual environment you created :
.venv/bin/python3 bot.py
- To bring the bot down press control+ c
- Clone the repo in a directory of your choosing.
- Install docker at this link: https://docs.docker.com/get-docker/
- Make a file named
.env
- Paste this line into
.env
and insert your discord bot token:DISCORD_TOKEN = "your token here"
- Run:
source up.sh
- To bring the bot down run:
source down.sh
- Clone the repo using
git clone https://github.com/cs220s22/DiscordBot.git
- Create a Heroku account if you do not already have one
- Create a new Heroku app on the site
- From the Settings tab, configure your environmental variables to add your bot key to the
DISCORD_TOKEN
variable - From the Settings tab, add the
heroku/python
build package to your application
- Install Heroku CLI (tutorial below)
- Login on CLI
- Once logged in add the heroku app to your git remotes using the following command
heroku git:remote -a your-app-name
- In the terminal run
heroku stack:set container
- Deploy your app using
git push heroku main
- Run
heroku-up.sh
- When done, run
heroku-down.sh
References used: (Install the Heroku CLI|https://devcenter.heroku.com/articles/heroku-cli#install-the-heroku-cli) (Heroku tutorial|https://devcenter.heroku.com/articles/build-docker-images-heroku-yml)
- Create EC2 instance
- create Key pair name and save the file to be able to connect to the instance
- You must create security group to allow http port 80 and if you want to connect to the instance allow port 22 to connect to the instance.
- click on advanced details then go to the user data field and copy paste the following commands with consideration pasting your own discord token
#!/bin/bash
sudo yum update
sudo yum install -y git
git clone https://github.com/cs220s22/DiscordBot.git
cd DiscordBot
python3 -m venv .venv
.venv/bin/pip3 install -r requirements.txt
touch .env
echo ""DISCORD_TOKEN="Enter your own Discord Token" > .env
sudo .venv/bin/python3 bot.py
- Update the packages on your system
- Installing git commands with a switch
-y
skips the user inputs - Clone DiscordBot repo
- Change directory to DiscordBot
- creating virtual environment with a switch
-m
creeating a module - going to the module and install the requirements with a switch
-r
to install all the libraries in the file. - Create .env file
- Write discord token key
- run the bot.py using virtual environment