A tool to aid Overwatch content creator mL7 determine what are the top upvoted user-submitted challenges in his community Discord server for his Spinning Wheel Challenge.
To invite the bot your server, click here.
Use the following command to upgrade packages in requirements.txt
:
pip install -U -r requirements.txt
These instructions are mostly for myself, so I can remember how to re-install the project.
After cloning the repo, create a virtual environment and activate it:
python3 -m venv .venv
source .venv/bin/activate
Now you can install the packages using the requirements file:
pip install -r requirements.txt
The following command creates a .env
file containing our environment variables:
echo -e "DISCORD_TOKEN=\nCHANNEL_ID=\nUSER_ID=\n" >> .env
Head to https://discord.com/developers/applications and Create a New Application.
After creating your application, head to the Bot tab and create a new bot.
Then add the bot to a server using the OAuth2 tab, scroll down to scopes, check bot and visit the generated URL.
To obtain the CHANNEL_ID
and USER_ID
, enable Developer Mode on Discord. User Settings > Advanced > Developer Mode.
DISCORD_TOKEN
can be found in the Bot tab. Copy it and append to our.env
file.CHANNEL_ID
can be obtained by right-clicking the channel and selecting "Copy ID"USER_ID
can be obtained by right-clicking the user and selecting "Copy ID"
To run the script for the bot, simply run
python3 bot.py
I use PM2 to run the bot as a process in the background.
To install PM2:
npm install -g pm2
In the project directory, start the bot:
pm2 start bot.py --interpreter=/usr/bin/python3
pm2 list list all pm2 processes
pm2 stop bot.py stop the bot
pm2 restart bot.py restart the bot
When starting the bot for the first time, if you get the following error:
ModuleNotFoundError: No module named 'discord'
Run the command:
pm2 start bot.py --interpreter python3 --interpreter-args -u
This will flush everything [Stackoverflow].