discRedit is a simple Discord bot coded in Python that fetches a random submission from a specified subreddit and sends it to the current channel. It is designed to run on Replit and be deployed on a Replit HTTP server, but can be modified to be hosted on other platforms. APIs used include discord.py and Async PRAW.
This bot was made with reference to the beginner's tutorial to create a Discord bot by freeCodeCamp.
Command | Description |
---|---|
.dr r/<subreddit name> |
Sends a random submission from the subreddit (sorted by Hot by default) to the current channel. |
.dr nsfw |
Toggles whether to show posts from NSFW subreddits. |
.dr sort <type> <time filter> |
Changes how a subreddit is sorted before a random submission is chosen. Options for type are hot , new , rising and top . If top , the time filter can be specified with one of all , day , hour , month , week , year . |
.dr settings |
Shows the current settings. |
-
You need to have accounts for Replit, Discord, Reddit and UptimeRobot.
-
Create applications for Discord (via the Discord Developer Portal) and Reddit.
-
Install the
discord
,asyncpraw
andFlask
packages on Replit. -
Create a new Repl and upload all three of
main.py
,keep_alive.py
andrestarter.py
. -
Create secrets inside Replit for your Discord token, Reddit secret and Reddit client ID. The keys for each secret should then replace the strings inside the square brackets in lines 9, 10 and 11 of
main.py
. Also replaceREDDIT_USERNAME
in line 15 with your Reddit username (with which you create the Reddit app). -
Run
main.py
inside Replit. A new window should appear in the top right. Copy the URL. -
Go to UptimeRobot and add a new monitor. Monitor type is HTTP(s). Enter any friendly name you like. Paste the copied URL into the URL field. With a free account, the shortest monitoring interval we can use is 5 minutes. This is fine for Replit.
-
If you are using a free UptimeRobot account, uncheck any options only available for paid users. Leave other options as default and create the monitor.
-
Add the bot to your servers using the Discord Developer Portal.