Skip to content

Commit fcdcfc2

Browse files
committed
Initial Commit
Final Release - Updates queued
1 parent d15f22a commit fcdcfc2

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
discordBotToken: "",
3+
discord_channel: "",
4+
messageText: "Hello @everyone, **{author}** just now uploaded a video!\n{url}",
5+
channel_id: "",
6+
refreshInterval: 30000
7+
}

index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const {Discord, Client, Collection, Message, MessageEmbed} = require("discord.js");
2+
const dClient = new Client({intents: 32767});
3+
dClient.db = require("quick.db");
4+
dClient.request = new(require("rss-parser"))();
5+
dClient.config = require("./config.js");
6+
7+
dClient.on("ready", () => {
8+
console.log(`Started following Youtube [ID] ${dClient.config.channel_id}`);
9+
console.log(`For Support please join https://discord.gg/PrGCCWpDbP`)
10+
handleUploads();
11+
});
12+
13+
function handleUploads() {
14+
if (dClient.db.fetch(`postedVideos`) === null) dClient.db.set(`postedVideos`, []);
15+
setInterval(() => {
16+
dClient.request.parseURL(`https://www.youtube.com/feeds/videos.xml?channel_id=${dClient.config.channel_id}`)
17+
.then(data => {
18+
if (dClient.db.fetch(`postedVideos`).includes(data.items[0].link)) return;
19+
else {
20+
dClient.db.set(`videoData`, data.items[0]);
21+
dClient.db.push("postedVideos", data.items[0].link);
22+
const parsed = dClient.db.fetch(`videoData`);
23+
const channel = dClient.channels.cache.get(dClient.config.discord_channel);
24+
if (!channel) return;
25+
const message = dClient.config.messageText
26+
.replace(/{author}/g, parsed.author)
27+
.replace(/{url}/g, parsed.link);
28+
channel.send(message);
29+
console.log(`[YOUTUBE] Sent Video Update to ${dClient.config.discord_channel}`)
30+
}
31+
});
32+
}, dClient.config.refreshInterval);
33+
}
34+
35+
dClient.login(dClient.config.discordBotToken);

0 commit comments

Comments
 (0)