Draft#
- class praw.models.Draft(reddit: praw.Reddit, id: Optional[str] = None, _data: Dict[str, Any] = None)#
A class that represents a Reddit submission draft.
Typical Attributes
Note
This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.
If you would like to add an attribute to this table, feel free to open a pull request.
Attribute
Description
link_flair_template_idThe link flair’s ID.
link_flair_textThe link flair’s text content, or
Noneif not flaired.modifiedTime the submission draft was modified, represented in Unix Time.
original_contentWhether the submission draft will be set as original content.
selftextThe submission draft’s selftext.
Noneif a link submission draft.spoilerWhether the submission will be marked as a spoiler.
subredditProvides an instance of
SubredditorUserSubreddit(if set).titleThe title of the submission draft.
urlThe URL the submission draft links to.
- __init__(reddit: praw.Reddit, id: Optional[str] = None, _data: Dict[str, Any] = None)#
Initialize a
Draftinstance.
- delete()#
Delete the
Draft.Example usage:
draft = reddit.drafts("124862bc-e1e9-11eb-aa4f-e68667a77cbb") draft.delete()
- classmethod parse(data: Dict[str, Any], reddit: praw.Reddit) Any#
Return an instance of
clsfromdata.- Parameters:
data – The structured data.
reddit – An instance of
Reddit.
- submit(*, flair_id: Optional[str] = None, flair_text: Optional[str] = None, nsfw: Optional[bool] = None, selftext: Optional[str] = None, spoiler: Optional[bool] = None, subreddit: Optional[Union[str, praw.models.Subreddit, praw.models.UserSubreddit]] = None, title: Optional[str] = None, url: Optional[str] = None, **submit_kwargs) praw.models.Submission#
Submit a draft.
- Parameters:
flair_id – The flair template to select (default:
None).flair_text – If the template’s
flair_text_editablevalue isTrue, this value will set a custom text (default:None).flair_idis required whenflair_textis provided.nsfw – Whether or not the submission should be marked NSFW (default:
None).selftext – The Markdown formatted content for a
textsubmission. Use an empty string,"", to make a title-only submission (default:None).spoiler – Whether or not the submission should be marked as a spoiler (default:
None).subreddit – The subreddit to submit the draft to. This accepts a subreddit display name,
Subredditobject, orUserSubredditobject.title – The title of the submission (default:
None).url – The URL for a
linksubmission (default:None).
- Returns:
A
Submissionobject for the newly created submission.
Note
Parameters set here will override their respective
Draftattributes.Additional keyword arguments are passed to the
Subreddit.submit()method.For example, to submit a draft as is:
draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e") submission = draft.submit()
For example, to submit a draft but use a different title than what is set:
draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e") submission = draft.submit(title="New Title")
See also
submit()to submit url posts and selftextssubmit_gallery(). to submit more than one image in the same postsubmit_image()to submit imagessubmit_poll()to submit pollssubmit_video()to submit videos and videogifs
- update(*, flair_id: Optional[str] = None, flair_text: Optional[str] = None, is_public_link: Optional[bool] = None, nsfw: Optional[bool] = None, original_content: Optional[bool] = None, selftext: Optional[str] = None, send_replies: Optional[bool] = None, spoiler: Optional[bool] = None, subreddit: Optional[Union[str, praw.models.Subreddit, praw.models.UserSubreddit]] = None, title: Optional[str] = None, url: Optional[str] = None, **draft_kwargs)#
Update the
Draft.Note
Only provided values will be updated.
- Parameters:
flair_id – The flair template to select.
flair_text – If the template’s
flair_text_editablevalue isTrue, this value will set a custom text.flair_idis required whenflair_textis provided.is_public_link – Whether to enable public viewing of the draft before it is submitted.
nsfw – Whether the draft should be marked NSFW.
original_content – Whether the submission should be marked as original content.
selftext – The Markdown formatted content for a text submission draft. Use
Noneto make a title-only submission draft.selftextcan not be provided ifurlis provided.send_replies – When
True, messages will be sent to the submission author when comments are made to the submission.spoiler – Whether the submission should be marked as a spoiler.
subreddit – The subreddit to create the draft for. This accepts a subreddit display name,
Subredditobject, orUserSubredditobject.title – The title of the draft.
url – The URL for a
linksubmission draft.urlcan not be provided ifselftextis provided.
Additional keyword arguments can be provided to handle new parameters as Reddit introduces them.
For example, to update the title of a draft do:
draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e") draft.update(title="New title")