Build a Reddit Moderator Bot With Standard Library,, and Node.js in 10 Minutes

Oct 16, 2018 · 4 min read

If you’re a subreddit moderator, chances are you’ve received requests from community members to delete an inappropriate comment or ban an ill-mannered user. But it’s 2018 going on 2019 — we’re in the midst of the biggest tech era and spoiled with things like AI, automation and bots. We no longer need to perform menial tasks like monitoring subreddits. Together, we’re going to build a Reddit bot that will automatically check a subreddit for flagged comments in 3 easy steps.

Community members can use “!delete” (shown above) or “!ban” to request bot moderation

Whether you have no programming knowledge or 15 years of professional experience, you’ll be able to deploy this bot with Standard Library, the API development and hosting platform, in under 10 minutes.

If you’re not familiar with Standard Library, we’re a serverless platform that enables everyone (yes, everyone! Calling all PMs, designers, marketing teams, sales people, oh and engineers… 🙋) to build, ship, and integrate scalable APIs in a matter of seconds. With the help of our online editor,, you can do all of this right from your browser.


Step 1: Get the Reddit bot template

Estimated time: 30 seconds

Head over to in your browser and select (that’s me! 🤓👋) in the Community API Sources tab:

Name your API:

Once done, you’ll conveniently land in (Standard Library’s in-browser text editor) with the Reddit bot project code.

Step 2: Copy and paste

Estimated time: 2-5 minutes

This next step involves expert knowledge of the copy-and-paste skill to set some required environment variables. You’ll notice there are three sets of variables listed in your file: , , and . We’ll be deploying our code to the environment, so we only need to worry about the variables for this tutorial!

All fields are found in :

To retrieve your , right click between the quotation marks and select “Insert Library Token…”:

Right click to access this context menu

Keys prefaced with-* can be found on Reddit ( and are your moderator account’s username and password, respectively).

If you don’t already have a Reddit app, register for one here with your moderator account:

Copy the and :

Paste both into :

When your file is properly filled out like the above screenshot, the bot is ready for some preliminary testing.

Fill out the required parameters (definitions and screenshots below):

Parameter definitionssubreddit: the name of the subreddit you are moderating
threshold: what score do you want the comment to have in order to perform the requested action?
allowBanPermission: true (allow ban requests) / false (ignore ban requests)
Click Debug to launch the parameter editor

Then click the “Run” button, which will do 2 things: deploy the API and execute it.

Custom parameters

Congratulations, your bot is live! 😎 🎉 🎊

When you hit “Run”, your bot scanned through your subreddit for any comments flagged with !delete or !ban and reacted accordingly by starting a vote!

Step 3: Set it and forget it

Estimated time: 1 minute

Schedule the main function as a task

Now, the final step is to set a task to automate this process and have your bot check your subreddit every few minutes for flagged comments. You can do this in by scheduling a task, which will automatically execute the API you just created according to a schedule of your choosing.

Suggestion: depending on subreddit traffic, you might increase or decrease the frequency of bot invocation. A good start is to have the bot do a scan once every 5 minutes.

Once you click the “Schedule Task” button in the bottom right corner, your Reddit bot will scan to reply to any new !ban/!delete requests and perform these tasks on any comments that meet the score threshold according to the schedule you have chosen.

That’s it! 🌟


JavaScript news and opinion.

Thanks to Jacob Lee and Keith Horwood


Written by


Building stuff and trying to write about it



JavaScript news and opinion.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade