Draft¶
- class asyncpraw.models.Draft(reddit: asyncpraw.Reddit, id: str | None = 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. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async 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_id
The link flair’s ID.
link_flair_text
The link flair’s text content, or
None
if not flaired.modified
Time the submission draft was modified, represented in Unix Time.
original_content
Whether the submission draft will be set as original content.
selftext
The submission draft’s selftext.
None
if a link submission draft.spoiler
Whether the submission will be marked as a spoiler.
subreddit
Provides an instance of
Subreddit
orUserSubreddit
(if set).title
The title of the submission draft.
url
The URL the submission draft links to.
- __init__(reddit: asyncpraw.Reddit, id: str | None = None, _data: dict[str, Any] = None)¶
Initialize a
Draft
instance.
- await delete()¶
Delete the
Draft
.Example usage:
draft = await reddit.drafts("124862bc-e1e9-11eb-aa4f-e68667a77cbb") await draft.delete()
- await load()¶
Re-fetches the object.
This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any
RedditBase
object.await reddit_base_object.load()
- classmethod parse(data: dict[str, Any], reddit: asyncpraw.Reddit) AsyncPRAWBase ¶
Return an instance of
cls
fromdata
.- Parameters:
data – The structured data.
reddit – An instance of
Reddit
.
- await submit(*, flair_id: str | None = None, flair_text: str | None = None, nsfw: bool | None = None, selftext: str | None = None, spoiler: bool | None = None, subreddit: str | asyncpraw.models.Subreddit | asyncpraw.models.UserSubreddit | None = None, title: str | None = None, url: str | None = None, **submit_kwargs: Any) asyncpraw.models.Submission ¶
Submit a draft.
- Parameters:
flair_id – The flair template to select (default:
None
).flair_text – If the template’s
flair_text_editable
value isTrue
, this value will set a custom text (default:None
).flair_id
is required whenflair_text
is provided.nsfw – Whether or not the submission should be marked NSFW (default:
None
).selftext – The Markdown formatted content for a
text
submission. 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,
Subreddit
object, orUserSubreddit
object.title – The title of the submission (default:
None
).url – The URL for a
link
submission (default:None
).
- Returns:
A
Submission
object for the newly created submission.
Note
Parameters set here will override their respective
Draft
attributes.Additional keyword arguments are passed to the
Subreddit.submit()
method.For example, to submit a draft as is:
draft = await reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e") submission = await 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
- await update(*, flair_id: str | None = None, flair_text: str | None = None, is_public_link: bool | None = None, nsfw: bool | None = None, original_content: bool | None = None, selftext: str | None = None, send_replies: bool | None = None, spoiler: bool | None = None, subreddit: str | asyncpraw.models.Subreddit | asyncpraw.models.UserSubreddit | None = None, title: str | None = None, url: str | None = None, **draft_kwargs: Any)¶
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_editable
value isTrue
, this value will set a custom text.flair_id
is required whenflair_text
is 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
None
to make a title-only submission draft.selftext
can not be provided ifurl
is 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,
Subreddit
object, orUserSubreddit
object.title – The title of the draft.
url – The URL for a
link
submission draft.url
can not be provided ifselftext
is 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 = await reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e") await draft.update(title="New title")