SubredditRulesModeration

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

Contain methods to moderate subreddit rules as a whole.

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

subreddit = await reddit.subreddit("NAME")
await subreddit.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 = await reddit.subreddit("NAME")
rules = [rule async for rule in 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 = await subreddit.rules.mod.reorder(new_rules)
__init__(subreddit_rules: asyncpraw.models.reddit.rules.SubredditRules)

Initialize the SubredditRulesModeration class.

await add(short_name: str, kind: str, description: str = '', violation_reason: Optional[str] = None) → asyncpraw.models.reddit.rules.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:

subreddit = await reddit.subreddit("NAME")
await subreddit.rules.mod.add(
    short_name="No spam",
    kind="all",
    description="Do not spam. Spam bad"
)
await reorder(rule_list: List[asyncpraw.models.reddit.rules.Rule]) → List[asyncpraw.models.reddit.rules.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 = await reddit.subreddit("NAME")
rules = [rule async for rule in 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 = await subreddit.rules.mod.reorder(new_rules)