Home » Blog

Reddit-discord bot

 · 3 min · NullDev

Discord bot that scrapes r/forhire, so we get filtered posts and discord notifications.

bot reddit discord karlo_smircic karlo_kajba_simanic

This article shows our design of a basic discord bot we made. The bot scrapes data from r/forhire and displays it nicely in a channel on our discord server.

The Idea

Why?

The first question that comes to mind is “Why would we even need this?”. Once we started searching for freelance jobs on r/forhire we found it a bit clumsy. We wanted to make it a bit easier for us. One of the main things we missed are filters and notifications on new posts. We also wanted a way to let others know if we send a message to the person. Since we use discord as our communication platform, we decided to make a discord bot that would help us.

Technologies

After some time researching Reddit API and its interface with python we decided to create scripts. One was for scraping Reddit and getting the posts. The other one was for the discord bot.

Reddit scraper

Interface with Python

To easily use Reddit’s data with python we used PRAW. PRAW stands for Python Reddit API Wrapper. It is a Python package that allows simple access to Reddit’s API. It simplifies the usage of the API and the only thing you need to get it working is a correct user agent. If you need more information about the package, feel free to check out its GitHub page: https://github.com/praw-dev/praw.

Filtering

One of our design decisions was to add a filter to the posts. We decided to do this simply by searching for words inside the post. This isn’t the best way to do it, but it is the simplest. Just in case the filter missed something we still send the “unrelated” posts to discord.

Interface with Discord

Once we have the posts sorted, we send a Discord webhook to a channel.

The result

In the end, we get a message on discord every time somebody posts something related to what we do. It looks like this:

Image of the message

Discord bot

Main functionality

In the end, we wanted the discord bot to respond to our emoji reaction and depending on the reaction move the post from one channel to another. The first thing the bot does is to put default reactions.

Image of the reaction

If one of us reacts with the green dot it means we reached out to the person. The bot then moves the post to a different channel made only for reached-out posts. If we once again click the green dot the bot automatically creates a channel and roles for the project. This way we can just add the customer to our server and give them the role. This also simplifies communication with the customer, since everyone that is working on the project can see the chat.

If one of us reacts with the red dot it means we do not want that job and it automatically moves the post to an archive.

In the end, we have a few channels shown in the picture:

Image of the channels

Docker

Once we finished the whole project, we needed to host it on our server. We wanted to make it as easy as possible for us, so we decided to create a Docker image for the scripts. After we created the images, we easily hosted them with Portainer.

You’ve read it all

Thanks for reading the article. If you have any questions, feel free to contact us.

The project is available for free on GitHub: https://github.com/freelance-Alpha-Devs/reddit-discord-Bot.