reddit-helper
v1.0.2
Published
A helper to get new reddit posts from a subreddit
Downloads
3
Maintainers
Readme
Getting Started/Examples
async function setup(){
const Reddit = require("reddit-helper"),
reddit = new Reddit();
// Misc methods.
reddit.setLogging(true/false); // Logs when the package is looking through the subreddits.
reddit.setMinutes(1); // Sets the number of minutes to look for new posts, default: 1 minute.
reddit.author // Returns the author of the package.
reddit.version // Returns the version of the package.
// sub methods.
await reddit.sub.add("name") // Adds 1 subreddit to be watched.
await reddit.sub.remove("name") // Removes 1 subreddit from being watched.
reddit.sub.list() // Lists all subreddits you have being watched.
await reddit.sub.bulk.add(["name", "name2"]) // Adds multiple subreddits to be watched.
await reddit.sub.bulk.remove(["name", "name"]) // Removes multiple subreddits from being watched.
// .on methods.
reddit.on("ready", () => console.log(`The module is now ready`)) // This is emitted once the "start" function is called.
reddit.on("reddit_error", (err) => console.log(err.stack)); // This is emitted once the package has an error
reddit.on("post", (sub, data) => console.log(sub, data)); // This is emitted once new posts from that subreddit is "new" (sub: string, data: Array)
// Start
await reddit.start(); // This starts the operation to look for new posts.
};
setup();