praw-dev / praw

PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

Home Page:http://praw.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check Subreddit Supported Post Types

ElliotKillick opened this issue · comments

Describe the solution you'd like

Some subreddits like r/sysadmin only support text posts. How might one go about detecting that before, for example, attempting to create a link post only for it to fail?

I checked the PRAW Subreddit documentation and wasn't able to find anything on it.

Describe alternatives you've considered

I tried can_assign_link_flair to see if that was it but it seems to be something different.

Additional context

No response

I believe there is an attribute (or several) for this. you can check the subreddit attributes after initializing and accessing a known attribute. Then you can do vars(subreddit) and take a look at what is returned by Reddit.

I'm having trouble locating the exact attribute inside there, do you happen to know what it is?

Ah, found it: submission_type

This is from r/pics. Each key is an attribute on a subreddit object.

{
 'allow_chat_post_creation': False,
 'allow_discovery': True,
 'allow_galleries': True,
 'allow_images': True,
 'allow_polls': False,
 'allow_predictions': False,
 'allow_predictions_tournament': False,
 'allow_talks': False,
 'allow_videogifs': True,
 'allow_videos': True,
 'submission_type': 'link',
}