This Discord bot facilitates a buddy pairing system, allowing users to be paired up with buddies for calls and handling various administrative tasks within the buddy system.
Set up a discord bot first! See below how!
-
Clone the Repository:
git clone https://github.com/Giveth/buddy-bot.git cd buddy-bot
-
Install Dependencies:
npm install
-
Environment Variables: Copy
.env.template
to.env
set all the needed values -
Run the Bot with hot reloading:
npm run dev
-
Go to the Discord Developer Portal.
-
Click on the "New Application" button and give it a name.
-
Navigate to the "Bot" tab on the left and click "Add Bot".
-
Under the "TOKEN" section, click "Copy" to get your bot token. This is what you'll set as
DISCORD_TOKEN
in your.env
file. -
Under the "OAuth2" tab, under "OAuth2 URL Generator", select the following scopes:
bot
. -
Under "Bot Permissions", select:
Send Messages
Read Message History
View Channels
Manage Roles
(for role-based actions, use with caution)Attach Files
(for audio transcription)
-
Using the generated URL under "OAuth2 URL Generator", invite the bot to your server.
Updating the Contributors Sheet:
- Admin users can type
!fillSheet
to update the contributors sheet with all people who possess the "Contributor" role. !pairUp
(ADMIN only) - Automate the creation of "buddy pairings" from a list of names and User IDs.
Pairing Contributors:
Admin users can type
Pairings are done manually for now.!pairContributors
in any channel to initiate the pairing process.
Start the buddy review process:
!dmBuddy @Username
(ADMIN only) - Start the buddy feedback process for a pair of user (contributor) and buddy:- The contributor and buddy get a DM that its time for their buddy feedback call and the contributor is asked for the date and time. The state is set to
awaitingDate
. - Once the date and time are submitted to the buddy-bot via DM (by the contributor) the state is set to
date set
and the date is recorded in the google sheet. - A message is posted to the
ANNOUNCEMENT_CHANNEL
that a buddy call is about to happen and is asking the community for feedback.
- The contributor and buddy get a DM that its time for their buddy feedback call and the contributor is asked for the date and time. The state is set to
After the buddy call:
!checkCalls
(ADMIN only) - Checks the backend sheet for Buddy calls that happened at leaste 1 hour ago with a Status of "date set". For all pairs it can find this condition to be true, it will DM them and ask: "Did the buddy call happen?". If the answer is yes, we change **Status to "paired no date", delete the Buddycalldate and save the current date in "Lastcall" (please note that this function can be triggered manually, but there is also a cron job calling this function every hour
Feedback form helpers:
!selfReview
(ADMIN only) - Check the backend sheet for buddy pairs with the statedate set
and send the "self review form" to them.!DMselfReview @Username1 @Username2
(ADMIN only) - Buddy Bot sends a DM to @Username1&2 and invites them to fill out the "Self Review form"!adminFeedback @Contributor @Username1 @Username2
(ADMIN only) - Buddy Bot sends a DM to @Username1&2 and invites them to fill out the "feedback form" for the @Contributor!leaderFeedback @Leader @Username1 @Username2
(ADMIN only) - Buddy Bot sends a DM to @Username1&2 and invites them to fill out the "leader feedback form" for the @Leader
Contributor commands
!getFeedback @Username1 @Username2
- Buddy Bot sends a DM to @Username1&2 and invites them to fill out the "feedback form"
CRON jobs
- once a day, buddy-bot will check the Buddycalldate-column for calls scheduled for the following day. If it discovers a call to be scheduled it will send the relevant Doclink to the respective buddy. A message is sent to ANNOUNCEMENT_CHANNEL detailing the buddy pair that got notified.
- every hour buddy-bot will run the checkCalls() function to see if a buddy call took place within the last hour and then closing this buddy call round for the pair.
!checkDates
(ADMIN only) - Check for calls that occurred over 10 weeks ago!checkCalls
(ADMIN only) - Check if any calls happened recently and if yes ask for the notes-!askForNotes
- Send a DM asking for the buddy-call notes
- A cron job is packaged with the bot that will run !pairContributors
automatically every quarter
- Once the process has been started the announcement channel will announce the pairings for this round and send a DM to every participant, requesting a date and time for their feedback call.
- It is easier to send requests for Feedback and Self-Review now
- Another cron job will check the sheet every ten minutes for buddy calls that already happened
- One hour after a call, the contributors will get a DM asking them for their buddy feedback call notes
- The notes get sent to the relevant person in HR
-
Build the Docker image:
docker build -t your_bot_name .
-
Run the bot inside a Docker container:
docker run -d --name your-bot-name --restart always your_image_name
Ensure the bot has permission to read roles, send messages, read messages, and access message attachments. If using role-based actions like updating roles or checking member roles, ensure that the bot's role is higher in the server's role hierarchy than the roles it's managing.