'Can PRAW tell if a poster is the moderator of a sub?
I'm trying to determine if the owner of a comment or post is a mod of the specific subreddit it's in (not a moderator in general). At the moment I'm using the code:
if comment.author in self.mods:
And that seems to run, but I've no idea if it's actually doing the job or if I'm wasting time here. Can someone confirm that I've got this right, or suggest a better way?
Solution 1:[1]
Unsure as to what self.mods is but this would return a list of moderators for a subreddit if the author is a moderator. Source
# subreddit would be a string of the subreddit you wish to look at
def listMods(reddit, subreddit):
return [str(moderator) for moderator in reddit.subreddit(subreddit).moderator()]
and then checking if the author is a moderator could look something like:
mods = listMods(reddit, "dataisbeautiful")
if comment.author in mods:
# do what you need to after checking
reddit is your praw instance logged into your account
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew Ryan |
