SubredditModeration¶
-
class
asyncpraw.models.reddit.subreddit.
SubredditModeration
(subreddit: asyncpraw.models.Subreddit)¶ Provides a set of moderation functions to a Subreddit.
For example, to accept a moderation invite from subreddit
r/test
:subreddit = await reddit.subreddit("test") await subreddit.mod.accept_invite()
-
__init__
(subreddit: asyncpraw.models.Subreddit)¶ Create a SubredditModeration instance.
- Parameters
subreddit – The subreddit to moderate.
-
await
accept_invite
()¶ Accept an invitation as a moderator of the community.
-
edited
(only: Optional[str] = None, **generator_kwargs: Any) → Iterator[Union[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) → Iterator[asyncpraw.models.SubredditMessage]¶ Return a
ListingGenerator
for moderator messages.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: Optional[str] = None, mod: Optional[Union[asyncpraw.models.Redditor, str]] = None, **generator_kwargs: Any) → Iterator[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: Optional[str] = None, **generator_kwargs: Any) → Iterator[Union[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)
-
removal_reasons
() → asyncpraw.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:subreddit = await reddit.subreddit("NAME") async for removal_reason in subreddit.mod.removal_reasons: print(removal_reason)
A single removal reason can be retrieved via:
subreddit = await reddit.subreddit("NAME") await subreddit.mod.removal_reasons.get_reason("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[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, Union[str, int, bool]]¶ Return a dictionary of the subreddit’s current settings.
-
spam
(only: Optional[str] = None, **generator_kwargs: Any) → Iterator[Union[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) → Iterator[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) → Iterator[asyncpraw.models.SubredditMessage]¶ Return a
ListingGenerator
for unread moderator messages.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: 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
,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
,high
.spam_links – Spam filter strength for links. One of
all
,low
,high
.spam_selfposts – Spam filter strength for selfposts. One of
all
,low
,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
,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
,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 – “asyncpraw.models.Subreddit” karma required to edit and create wiki pages.
wikimode – One of
anyone
,disabled
,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:subreddit = await reddit.subreddit("test") sidebar = await subreddit.wiki.get_page("config/sidebar") await 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.
-