To create a Discord Bot, you must:
- have a Discord Account
- have a Discord server for the bot
- create a Discord bot in the Developer Portal, but DO NOT ADD to your server yet (Follow instructions here)
- create a
.env
file with your Bot Token and add this to your .gitignore (Discord will automatically regenerate your token if you accidentally upload it to Github).
NOTE: You dont need to include { } in the .env file.
# .env DISCORD_TOKEN={your-bot-token} DICORD_BOT_NAME={your-bot-name} TEST_GUILD_ID={your-guild-id} TESTING_BOT_TOKEN={test-bot-token} TEST_BOT_NAME={test-bot-name} TEST_BOT_APP_ID={test-bot-application-id} BARD_API_KEY={your-bard-api-key} VERSION={custom bot version}
NOTE: Run the bot before inviting it to your server in order for auto-initiate commands to run
This includes the following:
- Creating Instructor Role
- Adding server owner to Instructor Role
- Creating Bot channels
To run the Teacher's Pet Bot:
- Ensure you have the following installed:
- Clone this repo onto your local machine
- In the repository directory, run
pip install -r requirements.txt
- Run
python src/bot.py
to start the bot - Invite the bot to your server (Follow instructions here)
- NOTE: When using the OAuth2 URL Generator, make sure you check the box which gives your bot Administrative permissions
To run tests on the Teacher's Pet Bot:
- Create a second bot for testing
- Add the Test Bot's token to the
.env
file.
NOTE: You dont need to include { } in the .env file.
# .env DISCORD_TOKEN={your-bot-token} DICORD_BOT_NAME={your-bot-name} TEST_GUILD_ID={your-guild-id} TESTING_BOT_TOKEN={test-bot-token} TEST_BOT_NAME={test-bot-name} TEST_BOT_APP_ID={test-bot-application-id} BARD_API_KEY={your-bard-api-key} VERSION={custom bot version}
- In
test/tests.py
, update theTEST_GUILD_ID
to be the id of the server/guild you are testing in. - IMPORTANT(You will have two bots running at once for testing. One normal bot, one test bot): Start Teacher's Pet Bot by running one of the following commands in the root directory of the project:
- Without Coverage:
pytest src/bot.py
- With Coverage:
coverage run --source=./src -m pytest src/bot.py
- Without Coverage:
- Run the tests with
python test/tests.py
in the root directory of the project - If you collected coverage, run
coverage report
to see coverage details.
You must have an account for Discord [Link], GitHub [Link] , and Heroku [Link].
- Fork a copy of this repository by clicking the 'Fork' on the upper right-hand.
- Create an application for Heroku by clicking here.
- Under 'Deploy', do the following:
- Deployment Method => Connect your GitHub
- App connected to GitHub => Search for the forked repository
- Automatic Deploy => Enable Automatic Deploy (to redeploy after every commit)