Skip to content

Commit

Permalink
Update Gamey to 1.0.1
Browse files Browse the repository at this point in the history
Added User blacklist, Healthcheck & Bug Fixes
  • Loading branch information
Rabenherz112 authored Dec 7, 2022
2 parents 43dfa64 + 5c3551f commit b942dc6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion commands/Config/set-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = {
})
.setFooter({
text: Embed.Footer,
iconURL: Embed.Icon,
iconURL: Embed.Footer_Icon,
});
return interaction.reply({ embeds: [embed] });
},
Expand Down
2 changes: 1 addition & 1 deletion commands/Config/set-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
})
.setFooter({
text: Embed.Footer,
iconURL: Embed.Icon,
iconURL: Embed.Footer_Icon,
});
interaction.reply({ embeds: [embed] });
},
Expand Down
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"slashCommandsGlobal": true,
"guildIDDev" : 843924725931049000,
"subreddits": ["FreeGameFindings","Freegamestuff"],

"_comment": "Users and URLs need to be in lowercase and without the https:// or http://",
"blacklistedURLs": ["gleam.io","givee.club"],
"blacklistedUsers": ["automoderator"],

"lookuptime": "30",
"limit" : "7",
Expand All @@ -20,7 +24,7 @@
},
"Embed" : {
"Footer" : "Gamey your free Games Finder",
"Footer_Icon" : "https://media.discordapp.net/attachments/731166978806644827/1047929202130825246/Gamey_Banner.png",
"Footer_Icon" : "https://media.discordapp.net/attachments/731166978806644827/1047599469610418227/Gamey_LogoTransparent.png",
"Thumbnail_Default" : "https://media.discordapp.net/attachments/731166978806644827/1047599468566036521/Gamey_BannerOnly.png"
}
}
29 changes: 25 additions & 4 deletions functions/util_checkReddit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
const { subreddits, lookuptime, limit, Embed, colors } = require("../config.json");
const { subreddits, lookuptime, limit, Embed, colors, blacklistedURLs, blacklistedUsers } = require("../config.json");
const { EmbedBuilder } = require("discord.js");
const { ChannelType } = require("discord-api-types/v10");
const { decode } = require("html-entities");

async function getSubredditData() {
// Health Check
let response = await fetch("https://www.reddit.com/");
if (response.status !== 200) {
console.log(`[REDDIT] Reddit is currently down, trying again in ${lookuptime} minutes`);
return;
}
// Get all new Posts from Subreddits
let allPosts = [];
for (let subreddit of subreddits) {
Expand Down Expand Up @@ -78,9 +84,24 @@ async function getPostsData(allPosts) {
let postDataUrl = post.data.url;
let postDataUrlPost = `https://www.reddit.com${post.data.permalink}`;
let postDataCreationTime = Math.floor(post.data.created_utc);
// Check if it is a Giveaway and if so don't send it
if (postDataUrl.toLowerCase().includes("gleam.io"))
// Check if postDataUrl is included in blacklistedURLs
let blacklisted = false;
for (let url of blacklistedURLs) {
if (postDataUrl.toLowerCase().includes(url)) {
blacklisted = true;
break;
}
}
// Check if postDataAuthor is a blacklistedUsers
for(let buser of blacklistedUsers) {
if (postDataAuthor.toLowerCase() == (buser)) {
blacklisted = true;
break;
}
}
if (blacklisted) {
continue;
}
let postDataId = post.data.id;
let subreddit = post.data.subreddit;
// Check for Launcher
Expand Down Expand Up @@ -180,7 +201,7 @@ async function sendNotification(posts) {
})
.setFooter({
text: Embed.Footer,
iconURL: Embed.Footer_Image
iconURL: Embed.Footer_Icon
})
.setTimestamp()

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-bot-free-games-finder",
"version": "1.0.0",
"version": "1.0.1",
"description": "Find your free Games and let them send you to Discord",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit b942dc6

Please sign in to comment.