I need to check the information about the last post made by a user using PRAW. I couldn't find any builtin functions that do this. Specifically, i need to check the amount of upvotes and karma received from the last post.
I was thinking maybe i could subtract the total karma after posting from the total karma before posting, but I don't have any idea on how to do that.
In general, there's no way to directly determine how much karma you got from any particular post or comment. In specific circumstances, such as if you have no other posts or comments, it could be possible, but this doesn't help in the general case.
You can, however, easily determine the score of posts and comments you have made. Score doesn't directly map into karma gained, as the higher score a comment or post has, the less karma each additional upvote gives you. Here's how to determine the scores of your recent posts and comments:
import praw
reddit = praw.Reddit( # fill in authentication
)
for submission in reddit.user.me().submissions.new(limit=5):
print(submission.score)
for comment in reddit.user.me().comments.new(limit=5):
print(comment.score)
If you just care about the single most recent item, set limit=1
. You can of course change the limit
parameter to whatever you like, including None
to get as many items as Reddit will give you (right around 1000).