ModeratorRelationship

class asyncpraw.models.reddit.subreddit.ModeratorRelationship(subreddit, relationship)

Provides methods to interact with a Subreddit’s moderators.

Moderators of a subreddit can be iterated through like so:

subreddit = await reddit.subreddit("test")
async for moderator in subreddit.moderator:
    print(moderator)
Parameters:
await __call__(redditor=None)

Return a list of Redditors who are moderators.

Parameters:

redditor (str | Redditor | None) – When provided, return a list containing at most one Redditor instance. This is useful to confirm if a relationship exists, or to fetch the metadata associated with a particular relationship (default: None).

Return type:

list[Redditor]

Note

To help mitigate targeted moderator harassment, this call requires the Reddit instance to be authenticated i.e., read_only must return False. This call, however, only makes use of the read scope. For more information on why the moderator list is hidden can be found here: https://support.reddithelp.com/hc/en-us/articles/360049499032-Why-can-t-I-see-the-list-of-moderators-in-a-community-

Note

Unlike other relationship callables, this relationship is not paginated. Thus, it simply returns the full list, rather than an iterator for the results.

To be used like:

subreddit = await reddit.subreddit("test")
moderators = await subreddit.moderator()

For example, to list the moderators along with their permissions try:

subreddit = await reddit.subreddit("test")
moderators = await subreddit.moderator()
for moderator in moderators:
    print(f"{moderator}: {moderator.mod_permissions}")
__init__(subreddit, relationship)

Initialize a SubredditRelationship instance.

Parameters:
  • subreddit (Subreddit) – The Subreddit for the relationship.

  • relationship (str) – The name of the relationship.

Return type:

None

await add(redditor, *, permissions=None, **other_settings)

Add or invite redditor to be a moderator of the Subreddit.

Parameters:
  • redditor (str | Redditor) – A redditor name or Redditor instance.

  • permissions (list[str] | None) – When provided (not None), permissions should be a list of strings specifying which subset of permissions to grant. An empty list [] indicates no permissions, and when not provided None, indicates full permissions (default: None).

  • other_settings (Any)

Return type:

None

An invite will be sent unless the user making this call is an admin user.

For example, to invite u/spez with "posts" and "mail" permissions to r/test, try:

subreddit = await reddit.subreddit("test")
await subreddit.moderator.add("spez", permissions=["posts", "mail"])
await invite(redditor, *, permissions=None, **other_settings)

Invite redditor to be a moderator of the Subreddit.

Parameters:
  • redditor (str | Redditor) – A redditor name or Redditor instance.

  • permissions (list[str] | None) – When provided (not None), permissions should be a list of strings specifying which subset of permissions to grant. An empty list [] indicates no permissions, and when not provided None, indicates full permissions (default: None).

  • other_settings (Any)

Return type:

None

For example, to invite u/spez with "posts" and "mail"

permissions to r/test, try:

subreddit = await reddit.subreddit("test")
await subreddit.moderator.invite("spez", permissions=["posts", "mail"])
invited(*, redditor=None, **generator_kwargs)

Return a ListingGenerator for Redditors invited to be moderators.

Parameters:
  • redditor (str | Redditor | None) – When provided, return a list containing at most one Redditor instance. This is useful to confirm if a relationship exists, or to fetch the metadata associated with a particular relationship (default: None).

  • generator_kwargs (Any)

Return type:

AsyncIterator[Redditor]

Additional keyword arguments are passed in the initialization of ListingGenerator.

Note

Unlike other usages of ListingGenerator, limit has no effect in the quantity returned. This endpoint always returns moderators in batches of 25 at a time regardless of what limit is set to.

Usage:

subreddit = await reddit.subreddit("test")
async for invited_mod in subreddit.moderator.invited():
    print(invited_mod)
await leave()

Abdicate the moderator position (use with care).

For example:

subreddit = await reddit.subreddit("test")
await subreddit.moderator.leave()
Return type:

None

await remove(redditor)

Remove redditor from this relationship.

Parameters:

redditor (str | Redditor) – A redditor name or Redditor instance.

Return type:

None

await remove_invite(redditor)

Remove the moderator invite for redditor.

Parameters:

redditor (str | Redditor) – A redditor name or Redditor instance.

Return type:

None

For example:

subreddit = await reddit.subreddit("test")
await subreddit.moderator.remove_invite("spez")
await update(redditor, *, permissions=None)

Update the moderator permissions for redditor.

Parameters:
  • redditor (str | Redditor) – A redditor name or Redditor instance.

  • permissions (list[str] | None) – When provided (not None), permissions should be a list of strings specifying which subset of permissions to grant. An empty list [] indicates no permissions, and when not provided, None, indicates full permissions (default: None).

Return type:

None

For example, to add all permissions to the moderator, try:

await subreddit.moderator.update("spez")

To remove all permissions from the moderator, try:

await subreddit.moderator.update("spez", permissions=[])
await update_invite(redditor, *, permissions=None)

Update the moderator invite permissions for redditor.

Parameters:
  • redditor (str | Redditor) – A redditor name or Redditor instance.

  • permissions (list[str] | None) – When provided (not None), permissions should be a list of strings specifying which subset of permissions to grant. An empty list [] indicates no permissions, and when not provided, None, indicates full permissions (default: None).

Return type:

None

For example, to grant the "flair" and "mail" permissions to the moderator invite, try:

await subreddit.moderator.update_invite("spez", permissions=["flair", "mail"])