UserSubredditModeration

class asyncpraw.models.reddit.user_subreddit.UserSubredditModeration(subreddit: asyncpraw.models.Subreddit)

Provides a set of moderation functions to a UserSubreddit.

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

redditor = await reddit.redditor("spez")
await redditor.subreddit.mod.accept_invite()
__init__(subreddit: asyncpraw.models.Subreddit)

Initialize a SubredditModeration instance.

Parameters:

subreddit – The subreddit to moderate.

await accept_invite()

Accept an invitation as a moderator of the community.

edited(*, only: str | None = None, **generator_kwargs: Any) AsyncIterator[asyncpraw.models.Comment | asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for item in subreddit.mod.edited(limit=None):
    print(item)
inbox(**generator_kwargs: Any) AsyncIterator[asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for message in subreddit.mod.inbox(limit=5):
    print("From: {}, Body: {}".format(message.author, message.body))
    for reply in message.replies:
        print("From: {}, Body: {}".format(reply.author, reply.body))
log(*, action: str | None = None, mod: asyncpraw.models.Redditor | str | None = None, **generator_kwargs: Any) AsyncIterator[asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for log in subreddit.mod.log(limit=5):
    print("Mod: {}, Subreddit: {}".format(log.mod, log.subreddit))
modqueue(*, only: str | None = None, **generator_kwargs: Any) AsyncIterator[asyncpraw.models.Comment | asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for item in subreddit.mod.modqueue(limit=None):
    print(item)
notes() asyncpraw.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 = await reddit.subreddit("test")

async for note in subreddit.mod.notes.redditors("spez"):
    print(f"{note.label}: {note.note}")
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:

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

A single removal reason can be retrieved via:

subreddit = await reddit.subreddit("test")
await subreddit.mod.removal_reasons.get_reason("reason_id")

Note

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

reports(*, only: str | None = None, **generator_kwargs: Any) AsyncIterator[asyncpraw.models.Comment | asyncpraw.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:

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

Return a dictionary of the Subreddit’s current settings.

spam(*, only: str | None = None, **generator_kwargs: Any) AsyncIterator[asyncpraw.models.Comment | asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for item in subreddit.mod.spam():
    print(item)
stream() asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for log in subreddit.mod.stream.log():
    print("Mod: {}, Subreddit: {}".format(log.mod, log.subreddit))
unmoderated(**generator_kwargs: Any) AsyncIterator[asyncpraw.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:

subreddit = await reddit.subreddit("mod")
async for item in subreddit.mod.unmoderated():
    print(item)
unread(**generator_kwargs: Any) AsyncIterator[asyncpraw.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:

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

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

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.