Rule

class asyncpraw.models.Rule(reddit: asyncpraw.Reddit, subreddit: asyncpraw.models.Subreddit | None = None, short_name: str | None = None, _data: Dict[str, str] | None = None)

An individual Rule object.

Typical Attributes

Note

This table describes attributes that typically belong to objects of this class. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.

If you would like to add an attribute to this table, feel free to open a pull request.

Attribute

Description

created_utc

Time the rule was created, represented in Unix Time.

description

The description of the rule, if provided, otherwise a blank string.

kind

The kind of rule. Can be "link", comment", or "all".

priority

Represents where the rule is ranked. For example, the first rule is at priority 0. Serves as an index number on the list of rules.

short_name

The name of the rule.

violation_reason

The reason that is displayed on the report menu for the rule.

__init__(reddit: asyncpraw.Reddit, subreddit: asyncpraw.models.Subreddit | None = None, short_name: str | None = None, _data: Dict[str, str] | None = None)

Initialize a Rule instance.

await load()

Re-fetches the object.

This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any RedditBase object.

await reddit_base_object.load()
mod() asyncpraw.models.reddit.rules.RuleModeration

Contain methods used to moderate rules.

To delete "No spam" from r/test try:

subreddit = await reddit.subreddit("test")
rule = await subreddit.rules.get_rule("No Spam")
await rule.mod.delete()

To update "No spam" from r/test try:

subreddit = await reddit.subreddit("test")
await subreddit.rules.get_rule("No spam")
await rule.mod.update(description="Don't do this!", violation_reason="Spam post")
classmethod parse(data: Dict[str, Any], reddit: asyncpraw.Reddit) Any

Return an instance of cls from data.

Parameters:
  • data – The structured data.

  • reddit – An instance of Reddit.