Google Classroom Discord Bot
(Working in progress)
Current progress:
- function to retrieve to-do assignments
- bot command to send the assignment list
- improvements on the speed of the assignments command
- bot command to get the timetable
- …
Commands:
( Bot prefix: $
)
test
The bot will reply with ‘test’.
For testing purposes.
assignments
Get assignment lists
Takes around 1 minute to run
Set-up
- requires: Google API OAuth2 Token (stored as
./credentials.json
) - discord bot (token stored in
./secrets.json
)
// secrets.json
{"token":"yourTokenHere"}
To get google api credentials:
- Visit Google Cloud Platform and sign in using your personal account (not your school account)
- Only education accounts aged 18 or above / perseonal accounts aged 13 or above can access to this service
- Create a new project for ‘web application’
- In the Libraries tab (under API & Services) search for ‘Google Classroom API’ and enable it
- In the Credentials tab (just below the Libraries tab), press ‘Create Credentials’ and choose OAuth client ID
- Set application type to ‘web application’, under the ‘Authorized redirect URIs field add uri ‘https:/6localhost:59821/
- Press Create and wait for a pop-up menu which says ‘OAuth client created’. In the menu press ‘DOWNLOAD JSON’
- Move the downloaded file to your working directory and rename it as
credentials.json
- run
py .\bot.py
in command prompt/terminal - A browser window will pop up, sign in and authorize using the school account ([email protected])
Creating a bot
- Go to Discord Developer Portal
- Create an application
- In the bot tab, create a bot
- In the URL Generator under OAuth2 Category in the sidebar, generate an URL and copy it
- with scopes “Bot”, “Messages.read” and “applications.commands”
- with bot permission “Administrator”
- In the bot tab, under Intents section, enable:
- PRESENCE INTENT
- SERVER MEMBERS INTENT
- MESSAGE CONTENT INTENT
- Go to the link obtained in step 4, complete the authorization to add the bot