Installation
Follow these steps to correctly install the script on your bot.
Installation Steps
Section titled “Installation Steps”-
Download the module & unzip the folder
Retrieve the module folder (often in .zip or .rar format) from the official source. Use a tool like WinRAR or 7-Zip to extract the script folder to your computer.
-
Creating your YouTube API keys
- Logging into the Google Developer platform
Go to: Dashboard to log in or create an account to access the dashboard.
- Create a project
Click on Create project, then enter the name of your project and confirm the creation.
- Activating the YouTube API on your Google account
Go to: YouTube API to activate the Google API.
-
Creating your application
Click on Credentials or go to this link: Credentials
Click on Create credentials, then choose API Keys
Fill in the following fields:
- Name (the name of your application, e.g.,
BotYoutube) - Application restrictions => IP Addresses and enter the IP address of your VPS/your machine
- In the API restrictions section, select YouTube Data API v3
Then confirm the creation. A key will be displayed for you to put in the
.envfile. - Name (the name of your application, e.g.,
- ⚠️ If you do not wish to pay, you have a daily quota to respect
Through the module, you can enter up to 5 YouTube accounts. If you want more, you will need to adjust it on the page Quotas
- Logging into the Google Developer platform
-
Configure the environment variables
Open the
.envfile provided with the script and add & modify the necessary environment variables for the proper functioning of the module.youtubeChannelID: ID of the channel where YouTube notifications will be sentyoutubeRoleID: ID of the role of people wishing to receive notifications (Generally the member role to notify the entire server or a role created by you so that members can choose this role to be notified of a new video!)youtubeAPIKey: The YouTube API key (See step 2)youtubeChannelFollowerID: ID of the voice channel that will be updated regarding the number of followers (Configure the account in the code, see the next step)
-
Copy/move the files/codes into your project
Copy the following files into the appropriate folders of your Discord bot project:
commands/notification/notification-add.js: in your commands foldercommands/notification/notification-list.js: in your commands foldercommands/notification/notification-remove.js: in your commands folderutils/notification/youtube.js: in your utilities folderutils/utils.js: in your utilities folder
Also, copy the indexing code of the module into your main
index.jsfile. In this file, we added prisma directly related to the “client” object, place this code in yours or adjust it according to your way of using prisma.❗ If you wish, you can modify PSEUDO_UPDATE_CHANNEL_STAT to update the statistics channel or comment this line. The pseudo must be the same as the one encoded in the database.
-
Update the database schema
Add the data model for retrieving notifications of new YouTube videos in your
prisma/schema.prismafile and run the necessary migrations to apply the changes to your database. Execute the following command:Terminal window npx prisma generatenpx prisma migrate dev --name add_youtube_notification -
Install the dependencies
Make sure the necessary dependencies are installed by checking your
package.jsonand running:Terminal window npm install -
Restart the bot
Restart your bot for the script to be taken into account.
- For the
/notification-addcommand, you need to enter the name of the YouTube channel indicated in the channel’s URL. Example: https://www.youtube.com/@Joyca => The name to enter when using the command is Joyca (without the @).