SubredditLinkFlairTemplates¶
-
class
asyncpraw.models.reddit.subreddit.
SubredditLinkFlairTemplates
(subreddit)¶ Provide functions to interact with link flair templates.
-
__init__
(subreddit)¶ Create a SubredditFlairTemplate instance.
- Parameters
subreddit – The subreddit whose flair templates to work with.
Note
This class should not be initialized directly. Instead obtain an instance via:
subreddit = await reddit.subreddit("subreddit_name") subreddit.flair.templates
or via
subreddit = await reddit.subreddit("subreddit_name") subreddit.flair.link_templates
-
await
add
(text, css_class='', text_editable=False, background_color=None, text_color=None, mod_only=None, allowable_content=None, max_emojis=None)¶ Add a link flair template to the associated subreddit.
- Parameters
text – The flair template’s text (required).
css_class – The flair template’s css_class (default: “”).
text_editable – (boolean) Indicate if the flair text can be modified for each Redditor that sets it (default: False).
background_color – The flair template’s new background color, as a hex color.
text_color – The flair template’s new text color, either
"light"
or"dark"
.mod_only – (boolean) Indicate if the flair can only be used by moderators.
allowable_content – If specified, most be one of
"all"
,"emoji"
, or"text"
to restrict content to that type. If set to"emoji"
then the"text"
param must be a valid emoji string, for example,":snoo:"
.max_emojis – (int) Maximum emojis in the flair (Reddit defaults this value to 10).
For example, to add an editable link flair try:
subreddit = await reddit.subreddit("NAME") await subreddit.flair.link_templates.add(css_class="praw", text_editable=True)
-
await
clear
()¶ Remove all link flair templates from the subreddit.
For example:
subreddit = await reddit.subreddit("NAME") await subreddit.flair.link_templates.clear()
-
await
delete
(template_id)¶ Remove a flair template provided by
template_id
.For example, to delete the first Redditor flair template listed, try:
async for template_info in subreddit.flair.templates: await subreddit.flair.templates.delete(template_info["id"]) break
-
staticmethod
flair_type
(is_link)¶ Return LINK_FLAIR or USER_FLAIR depending on
is_link
value.
-
await
update
(template_id, text=None, css_class=None, text_editable=None, background_color=None, text_color=None, mod_only=None, allowable_content=None, max_emojis=None, fetch=True)¶ Update the flair template provided by
template_id
.- Parameters
template_id – The flair template to update. If not valid then an exception will be thrown.
text – The flair template’s new text (required).
css_class – The flair template’s new css_class (default: “”).
text_editable – (boolean) Indicate if the flair text can be modified for each Redditor that sets it (default: False).
background_color – The flair template’s new background color, as a hex color.
text_color – The flair template’s new text color, either
"light"
or"dark"
.mod_only – (boolean) Indicate if the flair can only be used by moderators.
allowable_content – If specified, most be one of
"all"
,"emoji"
, or"text"
to restrict content to that type. If set to"emoji"
then the"text"
param must be a valid emoji string, for example,":snoo:"
.max_emojis – (int) Maximum emojis in the flair (Reddit defaults this value to 10).
fetch – Whether or not Async PRAW will fetch existing information on the existing flair before updating (Default: True).
Warning
If parameter
fetch
is set toFalse
, all parameters not provided will be reset to default (None
orFalse
) values.For example, to make a user flair template text_editable, try:
async for template_info in subreddit.flair.templates: await subreddit.flair.templates.update( template_info["id"], template_info["flair_text"], text_editable=True ) break
-