Listens to new pull requests from a Github repository and sends a message to a Discord text channel when a pull request is created. This is done through Github Webhooks, the Github API, and the Discordjs Bot Library.
Create or use a Discord bot with its own token and add it to your Discord server. To get the ID of a channel, you will need to enable developer mode.
Additionally, you will need to create or use a Github personal access token.
Create a .env
file (or add environmental variables) with the following information:
TOKEN="[Discord bot token]"
GH_USER="[Github Username]"
GH_AUTH="[Github personal access token]"
REPO="[Repository name (ie. MichaelZhao21/michaelzhao)]"
CHANNEL_ID="[ID of text channel to send messages to]"
PORT="[Port to use (optional)]"
Go to your repo Settings
and click on Webhooks
. Press Add Webhook
to add a new webhook:
- Under
Payload URL
, type in the URL of where you are hosting this program (The POST request is listening on the root path) - Change
Content type
toapplication/json
- Under
Which events would you like to trigger this webhook?
, selectLet me select individual events
and ONLY checkPull requests
- Then press
save
!
Simply type yarn start