gaber-elsayed

youtube noti

Sep 8th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. const http = require("http");
  2. const express = require("express");
  3. const app = express();
  4. var server = http.createServer(app);
  5.  
  6. app.get("/", (request, response) => {
  7. console.log(`Ping Received.`);
  8. response.writeHead(200, { "Content-Type": "text/plain" });
  9. response.end("DISCORD BOT YO");
  10. });
  11.  
  12. const listener = server.listen(process.env.PORT, function() {
  13. console.log(`Your app is listening on port ` + listener.address().port);
  14. });
  15.  
  16.  
  17. const discord = require("discord.js")
  18. const client = new discord.Client()
  19. const { TOKEN, CHANNEL_ID, SERVER_CHANNEL_ID } = require("./config.json");
  20. const YouTubeNotifier = require('youtube-notification');
  21.  
  22.  
  23. client.on("ready", () => {
  24. console.log("Watching " + CHANNEL_ID.length + " Channels")
  25. })
  26.  
  27. const notifier = new YouTubeNotifier({
  28. hubCallback: 'https://necessary-probable-slouch.glitch.me/yt',
  29. secret: 'JOIN_MY_SERVER_OR_DIE'
  30. });
  31.  
  32.  
  33. notifier.on('notified', data => {
  34. console.log('New Video');
  35. client.channels.cache.get(SERVER_CHANNEL_ID).send(
  36. `**${data.channel.name}** just uploaded a new video - **${data.video.link}**`
  37. );
  38. });
  39.  
  40. notifier.subscribe(CHANNEL_ID);
  41.  
  42. app.use("/yt", notifier.listener());
  43.  
  44.  
  45. client.login(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment