diff --git a/functions/util_checkReddit.js b/functions/util_checkReddit.js index d97b27a..bc5432c 100644 --- a/functions/util_checkReddit.js +++ b/functions/util_checkReddit.js @@ -102,8 +102,17 @@ async function getPostsData(allPosts) { if (blacklisted) { continue; } - let postDataId = post.data.id; - let subreddit = post.data.subreddit; + // Put the 3 latest Post Titles into the subreddit DB + await client.db.push(`${post.data.subreddit}.latestPosts`, postDataTitel.toLowerCase()); + let latestPosts = await client.db.get(`${post.data.subreddit}.latestPosts`); + if (latestPosts.length > 3) { + await client.db.shift(`${post.data.subreddit}.latestPosts`); + } + // Check if current Post Data Title is already in the DB + latestPosts = await client.db.get(`${post.data.subreddit}.latestPost`); + if (latestPosts.includes(postDataTitel.toLowerCase())) { + continue; + } // Check for Launcher let postDataLauncher = post.data.title.match(/^\[([a-zA-Z0-9 \.]+)(?:[\/, ]*[a-zA-Z0-9\. ]*)*\]+.*$/mi); if (postDataLauncher != null && typeof postDataLauncher === 'object' && postDataLauncher.length > 1) { diff --git a/package.json b/package.json index 2740612..9287fdd 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,10 @@ "homepage": "https://github.com/Rabenherz112/Discord-Bot-Free-Games-Finder#readme", "dependencies": { "better-sqlite3": "^8.0.1", - "discord-api-types": "^0.37.21", + "discord-api-types": "^0.37.24", "discord.js": "^14.7.1", "fs": "^0.0.1-security", "html-entities": "^2.3.3", - "quick.db": "^9.0.7" + "quick.db": "^9.0.8" } }