MCPcopy Create free account
hub / github.com/praw-dev/praw / create

Method create

praw/models/helpers.py:166–234  ·  view source on GitHub ↗

Create a new :class:`.Draft`. :param flair_id: The flair template to select (default: ``None``). :param flair_text: If the template's ``flair_text_editable`` value is ``True``, this value will set a custom text (default: ``None``). ``flair_id`` is required wh

(
        self,
        *,
        flair_id: str | None = None,
        flair_text: str | None = None,
        is_public_link: bool = False,
        nsfw: bool = False,
        original_content: bool = False,
        selftext: str | None = None,
        send_replies: bool = True,
        spoiler: bool = False,
        subreddit: (str | models.Subreddit | models.UserSubreddit | None) = None,
        title: str | None = None,
        url: str | None = None,
        **draft_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

164 return self._reddit.get(API_PATH["drafts"], params={"md_body": True})
165
166 def create(
167 self,
168 *,
169 flair_id: str | None = None,
170 flair_text: str | None = None,
171 is_public_link: bool = False,
172 nsfw: bool = False,
173 original_content: bool = False,
174 selftext: str | None = None,
175 send_replies: bool = True,
176 spoiler: bool = False,
177 subreddit: (str | models.Subreddit | models.UserSubreddit | None) = None,
178 title: str | None = None,
179 url: str | None = None,
180 **draft_kwargs: Any,
181 ) -> models.Draft:
182 """Create a new :class:`.Draft`.
183
184 :param flair_id: The flair template to select (default: ``None``).
185 :param flair_text: If the template's ``flair_text_editable`` value is ``True``,
186 this value will set a custom text (default: ``None``). ``flair_id`` is
187 required when ``flair_text`` is provided.
188 :param is_public_link: Whether to enable public viewing of the draft before it
189 is submitted (default: ``False``).
190 :param nsfw: Whether the draft should be marked NSFW (default: ``False``).
191 :param original_content: Whether the submission should be marked as original
192 content (default: ``False``).
193 :param selftext: The Markdown formatted content for a text submission draft. Use
194 ``None`` to make a title-only submission draft (default: ``None``).
195 ``selftext`` can not be provided if ``url`` is provided.
196 :param send_replies: When ``True``, messages will be sent to the submission
197 author when comments are made to the submission (default: ``True``).
198 :param spoiler: Whether the submission should be marked as a spoiler (default:
199 ``False``).
200 :param subreddit: The subreddit to create the draft for. This accepts a
201 subreddit display name, :class:`.Subreddit` object, or
202 :class:`.UserSubreddit` object. If ``None``, the :class:`.UserSubreddit` of
203 currently authenticated user will be used (default: ``None``).
204 :param title: The title of the draft (default: ``None``).
205 :param url: The URL for a ``link`` submission draft (default: ``None``). ``url``
206 can not be provided if ``selftext`` is provided.
207
208 Additional keyword arguments can be provided to handle new parameters as Reddit
209 introduces them.
210
211 :returns: The new :class:`.Draft` object.
212
213 """
214 if selftext and url:
215 msg = "Exactly one of 'selftext' or 'url' must be provided."
216 raise TypeError(msg)
217 if isinstance(subreddit, str):
218 subreddit = self._reddit.subreddit(subreddit)
219
220 data = Draft._prepare_data(
221 flair_id=flair_id,
222 flair_text=flair_text,
223 is_public_link=is_public_link,

Callers

nothing calls this directly

Calls 3

_prepare_dataMethod · 0.80
postMethod · 0.80
subredditMethod · 0.45

Tested by

no test coverage detected