SubredditLinkFlairTemplates

class praw.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: reddit.subreddit('subreddit_name').flair.templates or reddit.subreddit('subreddit_name').flair.link_templates.

__iter__()

Iterate through the link flair templates.

For example:

for template in reddit.subreddit('NAME').flair.link_templates:
    print(template)
add(text, css_class='', text_editable=False, background_color=None, text_color=None, mod_only=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: ‘’). Cannot be used in conjunction with background_color, text_color, or mod_only.
  • 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. Cannot be used in conjunction with css_class.
  • text_color – The flair template’s new text color, either 'light' or 'dark'. Cannot be used in conjunction with css_class.
  • mod_only – (boolean) Indicate if the flair can only be used by moderators. Cannot be used in conjunction with css_class.

For example, to add an editable link flair try:

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

Remove all link flair templates from the subreddit.

For example:

reddit.subreddit('NAME').flair.link_templates.clear()
delete(template_id)

Remove a flair template provided by template_id.

For example, to delete the first Redditor flair template listed, try:

template_info = list(subreddit.flair.templates)[0]
subreddit.flair.templates.delete(template_info['id'])
static flair_type(is_link)

Return LINK_FLAIR or USER_FLAIR depending on is_link value.

update(template_id, text, css_class='', text_editable=False, background_color=None, text_color=None, mod_only=None)

Update the flair template 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: ‘’). Cannot be used in conjunction with background_color, text_color, or mod_only.
  • 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. Cannot be used in conjunction with css_class.
  • text_color – The flair template’s new text color, either 'light' or 'dark'. Cannot be used in conjunction with css_class.
  • mod_only – (boolean) Indicate if the flair can only be used by moderators. Cannot be used in conjunction with css_class.

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

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

Note

Any parameters not provided will be set to default values (usually None or False) on Reddit’s end.