Pie-a-thon
Pie-a-thon

Reputation: 1

How do I make my Redditbot target-search a specific user, comment, and/or thread instead of an entire subreddit?

This is my first time coding, and as such I think my problem is most likely general confusion and difficulty with terms. I have the login function and the reply functions working on my bot, but I'm stuck at what command to use to narrow my bot's search-for-keyword range to a specific thread and or user, instead of an entire subreddit.

I've tried looking at the PRAW documentation and Build-A-Bot tutorials online, but I can't find any compatible commands in Python/PRAW to search a specific Redditor, comment, or subreddit thread.

This is the original command for PRAW that makes my bot search the subreddit for its key phrase:

for comment in r.subreddit('').comments(limit=25):

But I'm trying to hone it in on searching more specifically, so I tried this:

for comment in r.submission('#portion of the URL that has the submission ID in it').comments(limit=25):

But that just returns "TypeError: 'CommentForest' object is not callable."

I've also tried:

for comment in r.user('#Redditor name').comments(limit=25):

But that just returns "TypeError: 'User' object is not callable."

I have zero coding background and I'm actually having a lot of fun with Python thus far! I'm just stuck at this point. Any help and or suggestions would be appreciated!

Upvotes: 0

Views: 428

Answers (1)

PirateNinjas
PirateNinjas

Reputation: 2096

I think what you want is redditor rather than user. From the praw docs:

# assume you have a Submission instance bound to variable `submission`
redditor1 = submission.author
print(redditor1.name)  # Output: name of the redditor

# assume you have a Reddit instance bound to variable `reddit`
redditor2 = reddit.redditor('bboe')
print(redditor2.link_karma)  # Output: bboe's karma

You may have already seen them, but the docs can be found here.

Upvotes: 0

Related Questions