SubredditRelationship

class asyncpraw.models.reddit.subreddit.SubredditRelationship(subreddit: asyncpraw.models.Subreddit, relationship: str)

Represents a relationship between a Redditor and Subreddit.

Instances of this class can be iterated through in order to discover the Redditors that make up the relationship.

For example, banned users of a subreddit can be iterated through like so:

subreddit = await reddit.subreddit("test")
async for ban in subreddit.banned():
    print("{ban}: {ban.note}")
__call__(redditor: asyncpraw.models.Redditor | str | None = None, **generator_kwargs) AsyncIterator[asyncpraw.models.Redditor]

Return a ListingGenerator for Redditors in the relationship.

Parameters:

redditor – When provided, yield at most a single Redditor instance. This is useful to confirm if a relationship exists, or to fetch the metadata associated with a particular relationship (default: None).

Additional keyword arguments are passed in the initialization of ListingGenerator.

__init__(subreddit: asyncpraw.models.Subreddit, relationship: str)

Initialize a SubredditRelationship instance.

Parameters:
  • subreddit – The Subreddit for the relationship.

  • relationship – The name of the relationship.

await add(redditor: str | asyncpraw.models.Redditor, **other_settings: Any)

Add redditor to this relationship.

Parameters:

redditor – A redditor name or Redditor instance.

await remove(redditor: str | asyncpraw.models.Redditor)

Remove redditor from this relationship.

Parameters:

redditor – A redditor name or Redditor instance.