SubredditModeration

class praw.models.reddit.subreddit.SubredditModeration(subreddit: praw.models.Subreddit)

Provides a set of moderation functions to a Subreddit.

For example, to accept a moderation invite from r/test:

reddit.subreddit("test").mod.accept_invite()
__init__(subreddit: praw.models.Subreddit)

Initialize a SubredditModeration instance.

Parameters

subreddit – The subreddit to moderate.

accept_invite()

Accept an invitation as a moderator of the community.

edited(*, only: Optional[str] = None, **generator_kwargs: Any) Iterator[Union[praw.models.Comment, praw.models.Submission]]

Return a ListingGenerator for edited comments and submissions.

Parameters

only – If specified, one of "comments" or "submissions" to yield only results of that type.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print all items in the edited queue try:

for item in reddit.subreddit("mod").mod.edited(limit=None):
    print(item)
inbox(**generator_kwargs: Any) Iterator[praw.models.SubredditMessage]

Return a ListingGenerator for moderator messages.

Warning

Legacy modmail is being deprecated in June 2021. Please see https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/ for more info.

Additional keyword arguments are passed in the initialization of ListingGenerator.

See also

unread() for unread moderator messages.

To print the last 5 moderator mail messages and their replies, try:

for message in reddit.subreddit("mod").mod.inbox(limit=5):
    print(f"From: {message.author}, Body: {message.body}")
    for reply in message.replies:
        print(f"From: {reply.author}, Body: {reply.body}")
log(*, action: Optional[str] = None, mod: Optional[Union[praw.models.Redditor, str]] = None, **generator_kwargs: Any) Iterator[praw.models.ModAction]

Return a ListingGenerator for moderator log entries.

Parameters
  • action – If given, only return log entries for the specified action.

  • mod – If given, only return log entries for actions made by the passed in redditor.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print the moderator and subreddit of the last 5 modlog entries try:

for log in reddit.subreddit("mod").mod.log(limit=5):
    print(f"Mod: {log.mod}, Subreddit: {log.subreddit}")
modqueue(*, only: Optional[str] = None, **generator_kwargs: Any) Iterator[Union[praw.models.Comment, praw.models.Submission]]

Return a ListingGenerator for modqueue items.

Parameters

only – If specified, one of "comments" or "submissions" to yield only results of that type.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print all modqueue items try:

for item in reddit.subreddit("mod").mod.modqueue(limit=None):
    print(item)
notes() praw.models.SubredditModNotes

Provide an instance of SubredditModNotes.

This provides an interface for managing moderator notes for this subreddit.

For example, all the notes for u/spez in r/test can be iterated through like so:

subreddit = reddit.subreddit("test")

for note in subreddit.mod.notes.redditors("spez"):
    print(f"{note.label}: {note.note}")
removal_reasons() praw.models.reddit.removal_reasons.SubredditRemovalReasons

Provide an instance of SubredditRemovalReasons.

Use this attribute for interacting with a Subreddit’s removal reasons. For example to list all the removal reasons for a subreddit which you have the posts moderator permission on, try:

for removal_reason in reddit.subreddit("test").mod.removal_reasons:
    print(removal_reason)

A single removal reason can be lazily retrieved via:

reddit.subreddit("test").mod.removal_reasons["reason_id"]

Note

Attempting to access attributes of an nonexistent removal reason will result in a ClientException.

reports(*, only: Optional[str] = None, **generator_kwargs: Any) Iterator[Union[praw.models.Comment, praw.models.Submission]]

Return a ListingGenerator for reported comments and submissions.

Parameters

only – If specified, one of "comments" or "submissions" to yield only results of that type.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print the user and mod report reasons in the report queue try:

for reported_item in reddit.subreddit("mod").mod.reports():
    print(f"User Reports: {reported_item.user_reports}")
    print(f"Mod Reports: {reported_item.mod_reports}")
settings() Dict[str, Union[str, int, bool]]

Return a dictionary of the Subreddit’s current settings.

spam(*, only: Optional[str] = None, **generator_kwargs: Any) Iterator[Union[praw.models.Comment, praw.models.Submission]]

Return a ListingGenerator for spam comments and submissions.

Parameters

only – If specified, one of "comments" or "submissions" to yield only results of that type.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print the items in the spam queue try:

for item in reddit.subreddit("mod").mod.spam():
    print(item)
stream() praw.models.reddit.subreddit.SubredditModerationStream

Provide an instance of SubredditModerationStream.

Streams can be used to indefinitely retrieve Moderator only items from SubredditModeration made to moderated subreddits, like:

for log in reddit.subreddit("mod").mod.stream.log():
    print(f"Mod: {log.mod}, Subreddit: {log.subreddit}")
unmoderated(**generator_kwargs: Any) Iterator[praw.models.Submission]

Return a ListingGenerator for unmoderated submissions.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To print the items in the unmoderated queue try:

for item in reddit.subreddit("mod").mod.unmoderated():
    print(item)
unread(**generator_kwargs: Any) Iterator[praw.models.SubredditMessage]

Return a ListingGenerator for unread moderator messages.

Warning

Legacy modmail is being deprecated in June 2021. Please see https://www.reddit.com/r/modnews/comments/mar9ha/even_more_modmail_improvements/ for more info.

Additional keyword arguments are passed in the initialization of ListingGenerator.

See also

inbox() for all messages.

To print the mail in the unread modmail queue try:

for message in reddit.subreddit("mod").mod.unread():
    print(f"From: {message.author}, To: {message.dest}")
update(**settings: Union[str, int, bool]) Dict[str, Union[str, int, bool]]

Update the Subreddit’s settings.

See https://www.reddit.com/dev/api#POST_api_site_admin for the full list.

Parameters
  • all_original_content – Mandate all submissions to be original content only.

  • allow_chat_post_creation – Allow users to create chat submissions.

  • allow_images – Allow users to upload images using the native image hosting.

  • allow_polls – Allow users to post polls to the subreddit.

  • allow_post_crossposts – Allow users to crosspost submissions from other subreddits.

  • allow_videos – Allow users to upload videos using the native image hosting.

  • collapse_deleted_comments – Collapse deleted and removed comments on comments pages by default.

  • comment_score_hide_mins – The number of minutes to hide comment scores.

  • content_options – The types of submissions users can make. One of "any", "link", or "self".

  • crowd_control_chat_level – Controls the crowd control level for chat rooms. Goes from 0-3.

  • crowd_control_level – Controls the crowd control level for submissions. Goes from 0-3.

  • crowd_control_mode – Enables/disables crowd control.

  • default_set – Allow the subreddit to appear on r/all as well as the default and trending lists.

  • disable_contributor_requests – Specifies whether redditors may send automated modmail messages requesting approval as a submitter.

  • exclude_banned_modqueue – Exclude posts by site-wide banned users from modqueue/unmoderated.

  • free_form_reports – Allow users to specify custom reasons in the report menu.

  • header_hover_text – The text seen when hovering over the snoo.

  • hide_ads – Don’t show ads within this subreddit. Only applies to Premium-user only subreddits.

  • key_color – A 6-digit rgb hex color (e.g., "#AABBCC"), used as a thematic color for your subreddit on mobile.

  • language – A valid IETF language tag (underscore separated).

  • original_content_tag_enabled – Enables the use of the original content label for submissions.

  • over_18 – Viewers must be over 18 years old (i.e., NSFW).

  • public_description – Public description blurb. Appears in search results and on the landing page for private subreddits.

  • restrict_commenting – Specifies whether approved users have the ability to comment.

  • restrict_posting – Specifies whether approved users have the ability to submit posts.

  • show_media – Show thumbnails on submissions.

  • show_media_preview – Expand media previews on comments pages.

  • spam_comments – Spam filter strength for comments. One of "all", "low", or "high".

  • spam_links – Spam filter strength for links. One of "all", "low", or "high".

  • spam_selfposts – Spam filter strength for selfposts. One of "all", "low", or "high".

  • spoilers_enabled – Enable marking posts as containing spoilers.

  • submit_link_label – Custom label for submit link button (None for default).

  • submit_text – Text to show on submission page.

  • submit_text_label – Custom label for submit text post button (None for default).

  • subreddit_type – One of "archived", "employees_only", "gold_only", gold_restricted, "private", "public", or "restricted".

  • suggested_comment_sort – All comment threads will use this sorting method by default. Leave None, or choose one of "confidence", "controversial", "live", "new", "old", "qa", "random", or "top".

  • title – The title of the subreddit.

  • welcome_message_enabled – Enables the subreddit welcome message.

  • welcome_message_text – The text to be used as a welcome message. A welcome message is sent to all new subscribers by a Reddit bot.

  • wiki_edit_age – Account age, in days, required to edit and create wiki pages.

  • wiki_edit_karma – Subreddit karma required to edit and create wiki pages.

  • wikimode – One of "anyone", "disabled", or "modonly".

Note

Updating the subreddit sidebar on old reddit (description) is no longer supported using this method. You can update the sidebar by editing the "config/sidebar" wiki page. For example:

sidebar = reddit.subreddit("test").wiki["config/sidebar"]
sidebar.edit(content="new sidebar content")

Additional keyword arguments can be provided to handle new settings as Reddit introduces them.

Settings that are documented here and aren’t explicitly set by you in a call to SubredditModeration.update() should retain their current value. If they do not, please file a bug.