SubredditRedditorFlairTemplates

class praw.models.reddit.subreddit.SubredditRedditorFlairTemplates(subreddit)

Provide functions to interact with Redditor 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: reddit.subreddit('subreddit_name').flair.templates or reddit.subreddit('subreddit_name').flair.link_templates.

__iter__()

Iterate through the user flair templates.

add(text, css_class='', text_editable=False, is_link=False)

Add a Redditor 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).
  • is_link – (boolean) When True, add a link flair template rather than a Redditor flair template (default: False).

For example, to add an editable Redditor flair try:

reddit.subreddit('NAME').flair.templates.add(
    css_class='praw', text_editable=True)

Warning

The is_link parameter is deprecated. Use subreddit.flair.link_templates.add instead.

clear(is_link=False)

Remove all Redditor flair templates from the subreddit.

Parameters:is_link – (boolean) When True, clear all link flair templates rather than a Redditor flair templates (default: False).

For example:

reddit.subreddit('NAME').flair.templates.clear()

Warning

The is_link parameter is deprecated. Use subreddit.flair.link_templates.clear instead.

delete(template_id)

Remove a flair template provided by template_id.

flair_type(is_link)

Return LINK_FLAIR or USER_FLAIR depending on is_link value.

update(template_id, text, css_class='', text_editable=False)

Update the flair templated provided by template_id.

Parameters:
  • template_id – The flair template to update.
  • 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).

For example to make a link flair template text_editable, try:

template_info = list(subreddit.flair.templates)[0]
subreddit.flair.templates.update(
    template_info['flair_template_id'],
    text_editable=True)