PRAW Posting new submission with a flair?

413 Views Asked by At

Trying to post to a subreddit that requires flairs

reddit.subreddit('test').submit(title,url=link,flair_id='')

i didn't know how to find the flair_id of a subreddit ?

also when I try to share an image with praw using

Trying to post to a subreddit that requires flairs

reddit.subreddit('').submit_image(title,image_path=image,flair_id='')

how should i write the image path ?

2

There are 2 best solutions below

0
On BEST ANSWER

You can find the available flair ids with

reddit.subreddit("test").flair.templates

The image path is a path relative to the script

ex.

script/
     - main.py
     - image.png
reddit.subreddit('').submit_image(title, image_path="image.png")
0
On

The info to print flair_id can be found here

template_info = list(subreddit.flair.templates)[0]
subreddit.flair.templates.update(
template_info["id"],
text=template_info["flair_text"],
text_editable=True,
)

https://praw.readthedocs.io/en/latest/code_overview/other/subredditlinkflairtemplates.html#praw.models.reddit.subreddit.SubredditLinkFlairTemplates.user_selectable