SubredditRulesModeration

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

Contain methods to moderate subreddit rules as a whole.

To add rule "No spam" to r/test try:

subreddit = await reddit.subreddit("test")
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 r/test:

subreddit = await reddit.subreddit("test")
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: SubredditRules)

Initialize a SubredditRulesModeration instance.

await add(*, description: str = '', kind: str, short_name: str, violation_reason: str | None = None) asyncpraw.models.Rule

Add a removal reason to this subreddit.

Parameters:
  • description – The description for the rule.

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

  • short_name – The name of the rule.

  • 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 added Rule.

To add rule "No spam" to r/test try:

subreddit = await reddit.subreddit("test")
await subreddit.rules.mod.add(
    short_name="No spam", kind="all", description="Do not spam. Spam bad"
)
await reorder(rule_list: List[asyncpraw.models.Rule]) List[asyncpraw.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 r/test:

subreddit = await reddit.subreddit("test")
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)