Discord bot which performs auto moderation and notify about Twitch and YouTube channels that are live streaming. Bot can do a basic conversation. By using NLP.js, the bot can guess the language (currently English and French) and react to the user's message by a '👍' for positivity and '👎' for negativity. Twitch and YouTube live streams notifications and Twitch channels suggestions
Make sure you have installed all of this prerequisites
- Git - Download and install Git
- Node.js - Download and install Node.js which does also install NPM with it
- Docker - Download and install Docker
- Clone the repo
git clone https://github.com/AmineAML/DiscordBot.git
- Install NPM packages
npm install
- Rename
.env.example
file to.env
- Register your app and copy/paste the Client ID and Client Secret into
.env
file replacing their default values of TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET - Generate an Oauth and copy/paste it into
.env
file replacing the default value of TWITCH_OAUTH_TOKEN - You either use one of the following
- Sign up a new account or login into ngrok.com, you should obtain your AuthToken from the authentication tab of the dashboard, copy/paste it into
.env
file replacing the default value of NGROK_AUTHTOKEN - Sign up a new account or login into LocalXpose, you should obtain your access token from the acces tab of the dashboard, copy/paste it into
.env
file replacing the default value of LOCALXPOSE_ACCESS_TOKEN. And do modify the subdomain.
- Sign up a new account or login into ngrok.com, you should obtain your AuthToken from the authentication tab of the dashboard, copy/paste it into
- Follow this quickstart to get your YouTube Data API key, you don't have to do all of those steps, generate an API key and copy/paste it into
.env
file replacing the default value of YOUTUBE_API_KEY - Follow these steps to Set up a bot and copy/paste your Discord bot token into
.env
file replacing the default value of DISCORD_BOT_TOKEN - Add the bot to a server
- Enable you to subscribe to events, which when an event you subscribed to occurs, you're notified 1. Discord.js implements a variety of methods of working with webhooks 2.
- Use this doc for how to get your webhook url for a channel in your server, and copy/paste into
.env
file replacing the default value of DISCORD_CHANNEL_WEBHOOK - By subscribing to webhook of a Twitch channel, the Twitch API sends a notification to our server whenever that channel's live streaming. This option's using ngrok which generates a public URL to your localhost server, this URL's auto generated and constantly changes with each rebuild (although there's a paid plan with a constant URL). For production you can use your own domain by replacing the default value from
.env
of TWITCH_HUB_CALLBACK with it. - Part of the previous option, you can also use LocalXpose as an alternative to ngrok. The difference is that you can specify a custom subdomain to the public URL (or it also does generate it randomly), which's a better use case with the Twitch API as you can use the same public URL, but keep in mind that it does hold it for 15 mins after you're not using it, meaning that others could specify the same subdomain, that's why it's better to use a long string subdomain like a long word or a combination of words specific to your project (both ngrok and LocalXpose come with paid plans which allow you to reserve a subdomain or use your own domain).
- An easy way to get started with webhooks without using a bot, is by making use of IFTTT, you can follow this gist by smiley which goes into details of integrating a webhook which triggers a Disocrd notification. Keep in mind that this is specific to when your channel goes live, if you're like me insterested to trigger notifications of other Twitch channels that you follow going live, in step 4 of part 3 from the same gist choose "Stream going live for a channel you follow" rather than the option listed there (by using this option you limit yourself to only Twitch channels that you follow with your own account).
For development, specify which public URL tunnel you want to use
- Running with ngrok
npm run up --server=n
- Running with LocalXpose
npm run up --server=l
- A notification will ask you if you want to share
mongo-init.sh
file with Docker. Accept it
Edit the Dockerfile with the port you want to use and expose the same port (I'm using port 8080, you can modify it), also edit .env file values of Discord, Twitch API, YouTube API and the MONGODB_PRODUCTION_URL
as for node environment the Dockerfile handles it
- Build the docker image:
docker build -t your_image_name:version
- Your image is ready, you can try it by running a container based of it, tag it and push to a Docker registry for production