A Discord Bot which automatically generates a Watch2Gether room and add videos to it. Uses Discord.JS to interact with the Discord API, Spring to "build" the Watch2Gether room and Socket.IO for real time bidirectional communication between the Frontend and Backend
Sections:
- A Discord Bot which will serve as your Watch2Gether builder
- Docker for running the images.
You may also run the applications without Docker, but I trully recommend you to run with Docker.
- Java Development Kit 17 and Maven for compiling the "seleniumw2g" application
- Node.js to run the Discord Bot
- Some Web Server to host the Frontend (I usually use the Live Server extension for VSCode)
The first thing you should do is to create a file called "bot.json" inside "/discord-bot/backend/" containing the following parameters:
{
"token": "Your Token ID", // DO NOT EVER SEND YOUR BOT TOKEN ID TO ANYONE. NEVER. NEVER.
"guildId": "Your Guild ID"
}
The bot will only work within the selected guild because doing it for every guild would be extremely memory-consuming.
By default, the Watch2Gether Bot will only add Twitter and YouTube links to the Watch2Gether room. If you want to add one more platform, feel free to change it on "links.json" inside "/discord-bot/backend/", just be aware that some video players may not work well.
At the root of this repository, execute the following command into your Terminal:
docker-compose up -d
Obs.: to run without Docker you will need to execute each individual application (Selenium App, Backend and Frontend) on your local machine.
Then, if no mistakes were made, the Discord Bot will be online and the command /build will be available, as you can see below:
Before using the command, it's very important to open the Video Opener at your Web Browser. The address is "http://localhost:5500/". The reason why is explained here.
Now you may be able to use the /build command. On its usage, the Bot will try to find the last Watch2Gether link within the last 500 messages at the command's channel. Any link after the last Watch2Gether link will be parsed within the Bot and only the URLs which start with any link provided on "/discord-bot/backend/links.json" are going to be added to the room. If no Watch2Gether link was found, any link within the last 500 messages is going to be parsed.
Every URL within the command's channel which does not start with any link provided on "/discord-bot/backend/links.json" will not be added to the Watch2Gether room. Instead, it's going to be added to the "Alterinative videos". Also, some videos may failed to be added to the Watch2Gether room, which in this case are going to be added the "Non Working Videos". Therefore, these videos are available in the Video Opener which its address is, by default http://localhost:5500/. When the Bot finishes building the Watch2Gether room, the Video Opener webpage should look like this:
Dependencies of this repository:
- Spring Boot Starter Web
- Spring Boot DevTools
- Spring Boot Starter Test
- Selenium
- WebDriverManager
- Bean Validation API
Q: Why you didn't you use Node.js' Selenium instead of doing it using Java + Spring
- A: For some weird reason, Selenium on Node.js didn't work well, so I opted for the Java version.
Q: I found some bug, how can I report?
- A: Feel free to open an issue ticket or contact me on my e-mail: felipeflohrlol@gmail.com
Feel free to do whatever you want with this code :)