UserSubredditModeration

class praw.models.reddit.user_subreddit.UserSubredditModeration(subreddit)

Provides a set of moderation functions to a UserSubreddit.

For example, to accept a moderation invite from the user subreddit of u/spez:

reddit.subreddit("test").mod.accept_invite()
Parameters:

subreddit (models.Subreddit)

__init__(subreddit)

Initialize a SubredditModeration instance.

Parameters:

subreddit (Subreddit) – The subreddit to moderate.

Return type:

None

accept_invite()

Accept an invitation as a moderator of the community.

Return type:

None

edited(*, only=None, **generator_kwargs)

Return a ListingGenerator for edited comments and submissions.

Parameters:
  • only (str | None) – If specified, one of "comments" or "submissions" to yield only results of that type.

  • generator_kwargs (Any)

Return type:

Iterator[Comment | Submission]

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)
log(*, action=None, mod=None, **generator_kwargs)

Return a ListingGenerator for moderator log entries.

Parameters:
  • action (str | None) – If given, only return log entries for the specified action.

  • mod (Redditor | str | None) – If given, only return log entries for actions made by the passed in redditor.

  • generator_kwargs (Any)

Return type:

Iterator[ModAction]

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=None, **generator_kwargs)

Return a ListingGenerator for modqueue items.

Parameters:
  • only (str | None) – If specified, one of "comments" or "submissions" to yield only results of that type.

  • generator_kwargs (Any)

Return type:

Iterator[Submission | Comment]

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()

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}")
Return type:

SubredditModNotes

removal_reasons()

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 a nonexistent removal reason will result in a ClientException.

Return type:

SubredditRemovalReasons

reports(*, only=None, **generator_kwargs)

Return a ListingGenerator for reported comments and submissions.

Parameters:
  • only (str | None) – If specified, one of "comments" or "submissions" to yield only results of that type.

  • generator_kwargs (Any)

Return type:

Iterator[Submission | Comment]

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()

Return a dictionary of the Subreddit’s current settings.

Return type:

dict[str, str | int | bool]

spam(*, only=None, **generator_kwargs)

Return a ListingGenerator for spam comments and submissions.

Parameters:
  • only (str | None) – If specified, one of "comments" or "submissions" to yield only results of that type.

  • generator_kwargs (Any)

Return type:

Iterator[Submission | Comment]

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()

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}")
Return type:

SubredditModerationStream

unmoderated(**generator_kwargs)

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)
Return type:

Iterator[Submission]

Parameters:

generator_kwargs (Any)

update(**settings)

Update the Subreddit’s settings.

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_top – Allow the subreddit to appear on r/all as well as the default and trending lists.

  • 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.

  • 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.

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

  • description – Shown in the sidebar of your subreddit.

  • 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.

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

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

  • 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.

  • public_traffic – Make the traffic stats page public.

  • 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 – The string "user".

  • 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".

  • settings (str | int | bool)

Return type:

dict[str, str | int | bool]

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.

Warning

Undocumented settings, or settings that were very recently documented, may not retain their current value when updating. This often occurs when Reddit adds a new setting but forgets to add that setting to the API endpoint that is used to fetch the current settings.