The used file is placed in here (excluding authentication related files) Basically, I made it for my relatives to enjoy.
Also, there are two personal requirements for music bots,
――You can request songs as you like other than yourself --I want to keep the bot running
I decided to use google drive and heroku to meet these requirements.
.
├── Procfile
├── citron.py
├── client_secrets.json
├── commands.py
├── requirements.txt
├── runtime.txt
└── token.pickle
Description of each file
--citron.py: bot body --commands.py: List of commands that the bot responds to --client_secrets.json, token.pickle: google drive authentication related --Procfile, runtime.txt, requirements.txt: Required for Heroku deployment
docker pull python:3.7
docker images
#Container creation
docker run -d -it --name python --mount type=bind,source=path/to/mydir,target=/home/ python:3.7
#Enter the container
docker exec -it python bash
#The following operations in the container
python3 -m pip install -U discord.py
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
apt update
apt -y upgrade
apt install ffmpeg
I installed what I needed as needed, and finally it became like this. I don't care though it may contain unnecessary things.
requirements.txt
aiohttp==3.6.2
async-timeout==3.0.1
attrs==19.3.0
cachetools==4.0.0
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
discord.py==1.3.0
google-api-python-client==1.7.11
google-auth==1.11.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.1
httplib2==0.17.0
idna==2.8
multidict==4.7.4
oauth2client==4.1.3
oauthlib==3.1.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.19
PyDrive==1.3.1
PyNaCl==1.3.0
PyYAML==5.3
requests==2.22.0
requests-oauthlib==1.3.0
rsa==4.0
six==1.14.0
uritemplate==3.0.1
urllib3==1.25.8
websockets==8.1
yarl==1.4.2
youtube-dl==2020.1.24
Discord Bot https://discordapp.com/developers/applications/ This time I will ask Yuzu to DJ.
#Install Heroku CLI
brew install heroku/brew/heroku
heroku login
#Application creation
heroku create hoge
heroku open
#Deploy
git init
heroku git:remote -a <heroku app name>
git add .
git commit -m "first commit"
git push heroku master
Added build pack referring to here.
After that, I wrote it steadily while looking at the official document, but since it was clogged with google drive authentication, I will post only the changes.
#Change before
creds = flow.run_local_server(port=0)
#After change
creds = flow.run_console()
I wondered if it was related to testing with Docker or something related to the network, but I could not solve it and it ended up being after the change. If anyone knows, please let me know.
It works like this.
In the future, I would like to do something using DB as well. (Tell me the details of the song, the recommendation system, etc.)
--Paterrail: For log monitoring --Process Scheduler: Sleeps at midnight
Recommended Posts