SubredditRulesModeration

class praw.models.reddit.rules.SubredditRulesModeration(subreddit_rules: praw.models.reddit.rules.SubredditRules)

Contain methods to moderate subreddit rules as a whole.

To add rule "No spam" to the subreddit "NAME" try:

reddit.subreddit("NAME").rules.mod.add(
    short_name="No spam", kind="all", description="Do not spam. Spam bad"
)

To move the fourth rule to the first position, and then to move the prior first rule to where the third rule originally was in the subreddit "NAME":

subreddit = reddit.subreddit("NAME")
rules = list(subreddit.rules)
new_rules = rules[3:4] + rules[1:3] + rules[0:1] + rules[4:]
# Alternate: [rules[3]] + rules[1:3] + [rules[0]] + rules[4:]
new_rule_list = subreddit.rules.mod.reorder(new_rules)
__init__(subreddit_rules: praw.models.reddit.rules.SubredditRules)

Initialize the SubredditRulesModeration class.

add(short_name: str, kind: str, description: str = '', violation_reason: Optional[str] = None)praw.models.Rule

Add a removal reason to this subreddit.

Parameters
  • short_name – The name of the rule.

  • kind – The kind of item that the rule applies to. One of "link", "comment", or "all".

  • description – The description for the rule. Optional.

  • violation_reason – The reason that is shown on the report menu. If a violation reason is not specified, the short name will be used as the violation reason.

Returns

The Rule added.

To add rule "No spam" to the subreddit "NAME" try:

reddit.subreddit("NAME").rules.mod.add(
    short_name="No spam", kind="all", description="Do not spam. Spam bad"
)
reorder(rule_list: List[praw.models.Rule])List[praw.models.Rule]

Reorder the rules of a subreddit.

Parameters

rule_list – The list of rules, in the wanted order. Each index of the list indicates the position of the rule.

Returns

A list containing the rules in the specified order.

For example, to move the fourth rule to the first position, and then to move the prior first rule to where the third rule originally was in the subreddit "NAME":

subreddit = reddit.subreddit("NAME")
rules = list(subreddit.rules)
new_rules = rules[3:4] + rules[1:3] + rules[0:1] + rules[4:]
# Alternate: [rules[3]] + rules[1:3] + [rules[0]] + rules[4:]
new_rule_list = subreddit.rules.mod.reorder(new_rules)