I am currently trying to create a Discord bot (with Discord.py) that is able to search through Reddit every few hours to see if there is anything new that has been posted in a specific subreddit. Currently, I have a way to scrape Reddit for this information but it is activated through a Discord command. Ideally, I would like for the script to run automatically after a certain time interval instead of being activated through a command.
I am using asyncpraw and discord.py for my code, so it is all in Python. Additionally, I am using Flask to create a webserver for the bot, and then using Repl.it to host the server for free. I also use cron-job.org to submit a request every five minutes to the webserver in order to keep it running.
I have my files set up as main.py, which contains all information for the Discord bot, commands, and code that activates when the command is entered into the chat, and then a keep_alive.py file that contains the starting of the web server and the thread (I'm not super knowledgeable about Flask so I'm not super clear on what everything does). At the end of main.py, before I enter the discord bot's token, I call a function from keep_alive.py.
So far, I have tried to use cron-job.org to set up a cronjob, but it hasn't worked thus far as I am not super clear on how to go about it. I have also tried using schedule.py or sched.py, but neither has worked.
To my understanding, I need to use a cronjob for the functionality that I want, but I would love some guidance on actually implementing it, especially as far as the organization of files goes and where to call functions for them to activate. Additionally, I would like to find out if there is a way to use cronjobs within Repl.it, because I don't think you can use them from within their console.
Please let me know if you need any more information or code or anything else! I appreciate any and all help! Thanks!