Search code examples
pythonpraw

PRAW Comment and Sticky


I want to comment to a post, and sticky it straight away:

for submission in sub:
    if (submission.is_video or os.path.splitext(submission.url)[-1] in [".gif", ".gifv", ".mp4", ".webm"]) and submission.id not in get_old_submissions():
        submission.reply(MESSAGE)

I've tried iterating through the submissions comments, checking if the body is equal to the message, but my comment doesn't seem to show up at all:

        print(submission.comments.list())

Just gives []. Is there perhaps an easy way of getting the id of the new comment so I can pin it straight away?


Solution

  • .reply() returns a Comment object, so you can just assign that to a variable and then sticky it:

    comment = submission.reply()
    comment.mod.distinguish(sticky=True)