A simple node.js application that monitors BWC Members' Twitch channels for new streams and posts them to a Discord channel using a webhook.
- Twitch API (https://dev.twitch.tv/console/apps)
- Node.js (https://nodejs.org/en/download/) (v16.9.0 or higher)
- NPM (https://www.npmjs.com/get-npm) (should be installed with Node.js)
- PM2 (https://pm2.keymetrics.io/docs/usage/quick-start/) (Optional) - Used to run the application as a service.
- A Discord channel with a webhook.
- A list of BWC Members' Twitch usernames.
- Download the latest release from the releases page.
- Extract the zip file to a directory of your choice.
- Open a terminal window and navigate to the directory where you extracted the zip file.
- Run
npm installto install the required dependencies. - Run
npm run startto start the application. - The application will now be running in the terminal window. You can close the terminal window if you wish.
- To stop the application, press
CTRL + Cin the terminal window.
- Download the latest release from the releases page.
- Extract the zip file to a directory of your choice.
- Open a terminal window and navigate to the directory where you extracted the zip file.
- Run
npm installto install the required dependencies. - Run
pm2 start ecosystem.config.jsonto start the application as a service. You can then usepm2 stop <name>/<id>to stop the application, andpm2 restart name>/<id>to restart the application. - If you wish to run the application as a service on startup, you can use PM2 to do so. Run
pm2 startupto generate the startup command for your system. Then run the command that was generated to enable PM2 to run on startup. Then runpm2 saveto save the current PM2 configuration. You can then usepm2 stop name>/<id>to stop the application, andpm2 restart name>/<id>to restart the application.
- Open the
config.jsonfile in a text editor. - Replace the
messagevalue with the message you want to be sent to the Discord channel. - Add the members channel id to the
Streamersarray. - Save the
config.jsonfile.
- Open the ecosystem.config.json file in a text editor.
- Replace the
CLIENT_IDvalue with your Twitch API Client ID. - Replace the
CLIENT_SECRETvalue with your Twitch API Client Secret. - Replace the
WEBHOOK_URLvalue with the webhook url for your Discord channel. - Save the
ecosystem.config.jsonfile.
- The
messagevalue supports Discord markdown. - You can find the members' usernames by going to their Twitch channel and copying the last part of the URL. For example, the username for https://www.twitch.tv/bradleyw is
bradleyw.
The application uses the winston logger to log messages to the console and to a log file. The log file is named Youtube-API-Discord.log.
- Fork the repository.
- Create a new branch for your changes.
- Make your changes.
- Create a pull request.
- Enjoy!
If you have any questions, feel free to contact me at:
- BWC Discord
[BWC] Patrick - BWC Forums
Patrick.
- Twitch API
- Node.js - Application Development
- NPM - Package Management
- PM2 - Process Management
- Winston - Logging Library
- Discord.js - Discord API Library
