#
Developer Setup Guide
#
System Requirements
Install Node.js, select the Long Term Support
version.
#
Before we start
For the rest of this guide, we will assume that you are setting up for development use. For production:
- Fill in
YABOB/src/environment/production.json
instead ofYABOB/src/environment/development.json
- The run command is
npm run prod
instead ofnpm run dev
- Use
npm install --production
to skip installing dev dependencies
#
Step 1. Discord Developer Account, BOB App ID
Make a discord server.
Follow Discord's Official Documentation and create a bot account. For the bot permissions at step 6, choose Administrator.
Look for
APPLICATION ID
in the General Information tab. This is yourYABOB_APP_ID
.Look for
TOKEN
in the Bot tab (it has a reset token button next to it). This is yourYABOB_BOT_TOKEN
.In the Bot tab under Privileged Gateway Intents, enable SERVER MEMBERS INTENT.
In the OAuth2 \to URL Generator tab, select
bot
in scopes, then selectAdministrator
in bot permissions. Finally copy the generated URL at the bottom and paste it in your browser.Opening the link will prompt you to invite your YABOB instance! Simply choose the server that you want to invite YABOB to.
If you are inviting YABOB to a server with existing roles, YABOB will prompt you to give it the highest role. Once you have saved the role settings, YABOB will DM you again saying that it got the highest role. Make sure that YABOB's role name is the same as YABOB's username.
#
Clone the source code
git clone https://github.com/KaoushikMurugan/yet-another-better-office-hour-bot.git
- For simplicity we'll be referring to the project's root directory as YABOB for the rest of this page.
#
Step 2. Setup Firebase
Go to Google Firebase Console and sign in with a google account.
Click CREATE A PROJECT and follow the guide.
One the left \to All products \to Cloud Firestore, create a new database. Wait for it to finish.
One the left, Settings \to Project Settings \to Service Accounts \to Generate New Private Key. This will prompt you to download a JSON file.
Go to
YABOB/src/environment/production.json
"firebaseCredentials": { "projectId": "", "privateKey": "", "clientEmail": "" }
From the file you just downloaded:
- Put the value of
project_id
intoprojectId
- Put the value of
private_key
intoprivateKey
- Put the value of
client_email
intoclientEmail
- Put the value of
#
Step 3. Running YABOB without extensions
Go to
YABOB/src/environment/production.json
, fill in:"discordBotCredentials": { "YABOB_APP_ID": "", "YABOB_BOT_TOKEN": "" }
For example:
"discordBotCredentials": { "YABOB_APP_ID": "1234567890", "YABOB_BOT_TOKEN": "qwertyuoikhjgSDJAHGiqdhqweKDSHahjsgdzxvcbzxvcmbn" }
Install all the dependencies:
npm install
Now you can run the bot with the fundamental functionalities using this command: (Don't forget the space between the 2 dashes and
noExtensions
)npm run dev -- noExtensions=true
#
Step 4. Setting up extensions (optional)
Right now you have a functioning YABOB! To make YABOB more useful and customizable, we developed the extensions feature in v4. YABOB comes with 2 built in extensions:
Google Sheet Logging
Utilizes Google Sheets to track tutor/helper attendance and make sure they are following their schedules, as well as providing insights to how many help sessions are being held.
Session Calendar
Utilizes Google Calendar to display upcoming help sessions in the queue so that students can easily see when the next office hour session will happen.
#
Ignoring Credentials in Git
For development, run this command in the YABOB
directory:
git update-index --skip-worktree ./src/environment/*.json
This will ignore all changes in the credentials json files so they aren't accidentally pushed to the repository.
If the file structure changes in the future and requires new commits, run this:
git update-index --no-skip-worktree ./src/environment/*.json
and git will track these files again. Ignore the changes again after updates.
#
Google Sheet Logging Extension Requirements
#
Service Account Key
Go to Google Cloud and add your google account of choice.
Click Select a Project on the top left and create a new project.
Then go to API & Services \to Credentials tab \to Create Credentials \to Service Account.
Follow the guide to create a service account. Enable Owner Permission.
Once you are back at the Credentials tab, click on the account you just created \to KEYS \to Add Key: Create New Key \to Choose JSON \to It will prompt you to download your key.
Copy the corresponding values of this JSON file into
YABOB/src/environment/development.json
."googleCloudCredentials": { "client_email": "", "private_key": "" }
This
client_email
is the email of YABOB. We will share the google sheet with this email in the next step.
#
Google Sheets API
Still in the Google Cloud Console, go to APIs and Services \to Enabled APIs & Services.
Click on ENABLE APIS AND SERVICES.
Search for Google Sheets, Click on that then click ENABLE.
Search for Google Drive, enable this API as well.
Now we have access to google sheets, we just need the sheet itself.
#
Google Sheets ID
Create an empty Google Sheet and share the sheet to YABOB's service account email with EDIT access.
- This is the
client_email
field undergoogleCloudCredentials
- This is the
The google sheets URL looks like this:
https://docs.google.com/spreadsheets/d/<very long string here>/edit
That very long string is your
YABOB_GOOGLE_SHEET_ID
.Go to
YABOB/src/environment/development.json
. Fill inYABOB_GOOGLE_SHEET_ID
with the string you just found."googleSheetLogging": { "YABOB_GOOGLE_SHEET_ID": "" }
#
Calendar Extension Requirements
#
Google Calendar API
Create a google calendar.
Go to that particular calendar's
Settings and Sharing
tab. Tick the Make available to public checkbox.Scrolling down will take you do the Integrate Calendar Section. Copy the Calendar ID. It should end with
calendar.google.com
. This is yourYABOB_DEFAULT_CALENDAR_ID
and will be used as a fallback calendarGo to Google Cloud, then go to APIs and Services \to Enabled APIs & Services
Enable the Calendar API
Still in APIs and Services, go to Credentials \to CREATE CREDENTIALS: API KEY
Now you will be prompted with a long string. You can limit the scopes of this key by following the guide on screen. This is your
YABOB_GOOGLE_API_KEY
Go to
YABOB/src/environment/development.json
, fill in"sessionCalendar": { "YABOB_DEFAULT_CALENDAR_ID": "", "YABOB_GOOGLE_API_KEY": "" }
#
Final Check
Everything in YABOB/src/environment/development.json
should now have a value instead of an empty string.
#
Step 5. Running with Extensions
Remove the -- noExtension
flag from step 2.
npm run dev