ModeratorRelationship
- class praw.models.reddit.subreddit.ModeratorRelationship(subreddit: praw.models.Subreddit, relationship: str)
Provides methods to interact with a
Subreddit
’s moderators.Moderators of a subreddit can be iterated through like so:
for moderator in reddit.subreddit("test").moderator(): print(moderator)
- __call__(redditor: Optional[Union[praw.models.Redditor, str]] = None) List[praw.models.Redditor]
Return a list of
Redditor
s who are moderators.- Parameters
redditor – 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
).
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:
moderators = reddit.subreddit("test").moderator()
For example, to list the moderators along with their permissions try:
for moderator in reddit.subreddit("test").moderator(): print(f"{moderator}: {moderator.mod_permissions}")
- __init__(subreddit: praw.models.Subreddit, relationship: str)
Initialize a
SubredditRelationship
instance.- Parameters
subreddit – The
Subreddit
for the relationship.relationship – The name of the relationship.
- add(redditor: Union[str, praw.models.Redditor], *, permissions: Optional[List[str]] = None, **other_settings: Any)
Add or invite
redditor
to be a moderator of theSubreddit
.- Parameters
redditor – A redditor name or
Redditor
instance.permissions – 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 providedNone
, indicates full permissions (default: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:reddit.subreddit("test").moderator.add("spez", permissions=["posts", "mail"])
- invite(redditor: Union[str, praw.models.Redditor], *, permissions: Optional[List[str]] = None, **other_settings: Any)
Invite
redditor
to be a moderator of theSubreddit
.- Parameters
redditor – A redditor name or
Redditor
instance.permissions – 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 providedNone
, indicates full permissions (default:None
).
For example, to invite u/spez with
"posts"
and"mail"
permissions to r/test, try:reddit.subreddit("test").moderator.invite("spez", permissions=["posts", "mail"])
- invited(*, redditor: Optional[Union[praw.models.Redditor, str]] = None, **generator_kwargs: Any) Iterator[praw.models.Redditor]
Return a
ListingGenerator
forRedditor
s invited to be moderators.- Parameters
redditor – 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
).
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 whatlimit
is set to.Usage:
for invited_mod in reddit.subreddit("test").moderator.invited(): print(invited_mod)
- leave()
Abdicate the moderator position (use with care).
For example:
reddit.subreddit("test").moderator.leave()
- remove(redditor: Union[str, praw.models.Redditor])
Remove
redditor
from this relationship.- Parameters
redditor – A redditor name or
Redditor
instance.
- remove_invite(redditor: Union[str, praw.models.Redditor])
Remove the moderator invite for
redditor
.- Parameters
redditor – A redditor name or
Redditor
instance.
For example:
reddit.subreddit("test").moderator.remove_invite("spez")
- update(redditor: Union[str, praw.models.Redditor], *, permissions: Optional[List[str]] = None)
Update the moderator permissions for
redditor
.- Parameters
redditor – A redditor name or
Redditor
instance.permissions – 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
).
For example, to add all permissions to the moderator, try:
subreddit.moderator.update("spez")
To remove all permissions from the moderator, try:
subreddit.moderator.update("spez", permissions=[])
- update_invite(redditor: Union[str, praw.models.Redditor], *, permissions: Optional[List[str]] = None)
Update the moderator invite permissions for
redditor
.- Parameters
redditor – A redditor name or
Redditor
instance.permissions – 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
).
For example, to grant the
"flair"
and"mail"
permissions to the moderator invite, try:subreddit.moderator.update_invite("spez", permissions=["flair", "mail"])