Draft¶
- class praw.models.Draft(reddit, id=None, _data=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.
- Parameters:
reddit (praw.Reddit)
id (str | None)
- delete()¶
Delete the
Draft.Example usage:
draft = reddit.drafts("124862bc-e1e9-11eb-aa4f-e68667a77cbb") draft.delete()
- Return type:
- classmethod parse(data, reddit)¶
Return an instance of
clsfromdata.
- submit(*, flair_id=None, flair_text=None, nsfw=None, selftext=None, spoiler=None, subreddit=None, title=None, url=None, **submit_kwargs)¶
Submit a draft.
- Parameters:
flair_id (
str|None) – The flair template to select (default:None).flair_text (
str|None) – If the template’sflair_text_editablevalue isTrue, this value will set a custom text (default:None).flair_idis required whenflair_textis provided.nsfw (
bool|None) – Whether or not the submission should be marked NSFW (default:None).selftext (
str|None) – The Markdown formatted content for atextsubmission. Use an empty string,"", to make a title-only submission (default:None).spoiler (
bool|None) – Whether or not the submission should be marked as a spoiler (default:None).subreddit (
str|Subreddit|UserSubreddit|None) – The subreddit to submit the draft to. This accepts a subreddit display name,Subredditobject, orUserSubredditobject.title (
str|None) – The title of the submission (default:None).url (
str|None) – The URL for alinksubmission (default:None).submit_kwargs (Any)
- Return type:
- 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 make a submission directly.
- update(*, flair_id=None, flair_text=None, is_public_link=None, nsfw=None, original_content=None, selftext=None, send_replies=None, spoiler=None, subreddit=None, title=None, url=None, **draft_kwargs)¶
Update the
Draft.Note
Only provided values will be updated.
- Parameters:
flair_text (
str|None) – If the template’sflair_text_editablevalue isTrue, this value will set a custom text.flair_idis required whenflair_textis provided.is_public_link (
bool|None) – Whether to enable public viewing of the draft before it is submitted.nsfw (
bool|None) – Whether the draft should be marked NSFW.original_content (
bool|None) – Whether the submission should be marked as original content.selftext (
str|None) – The Markdown formatted content for a text submission draft. UseNoneto make a title-only submission draft.selftextcan not be provided ifurlis provided.send_replies (
bool|None) – WhenTrue, messages will be sent to the submission author when comments are made to the submission.spoiler (
bool|None) – Whether the submission should be marked as a spoiler.subreddit (
str|Subreddit|UserSubreddit|None) – The subreddit to create the draft for. This accepts a subreddit display name,Subredditobject, orUserSubredditobject.url (
str|None) – The URL for alinksubmission draft.urlcan not be provided ifselftextis provided.draft_kwargs (Any)
- Return type:
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")