SubredditModeration¶
-
class
praw.models.reddit.subreddit.
SubredditModeration
(subreddit)¶ Provides a set of moderation functions to a Subreddit.
-
__init__
(subreddit)¶ Create a SubredditModeration instance.
Parameters: subreddit – The subreddit to moderate.
-
accept_invite
()¶ Accept an invitation as a moderator of the community.
-
edited
(only=None, **generator_kwargs)¶ 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)¶ Return a
ListingGenerator
for moderator messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.See
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("From: {}, Body: {}".format(message.author, message.body)) for reply in message.replies: print("From: {}, Body: {}".format(reply.author, reply.body))
-
log
(action=None, mod=None, **generator_kwargs)¶ 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("Mod: {}, Subreddit: {}".format(log.mod, log.subreddit))
-
modqueue
(only=None, **generator_kwargs)¶ 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)
-
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('NAME').mod.removal_reasons: print(removal_reason)
A single removal reason can be lazily retrieved via:
reddit.subreddit('NAME').mod.removal_reasons['reason_id']
Note
Attempting to access attributes of an nonexistent removal reason will result in a
ClientException
.
-
reports
(only=None, **generator_kwargs)¶ 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("User Reports: {}".format(reported_item.user_reports)) print("Mod Reports: {}".format(reported_item.mod_reports))
-
settings
()¶ Return a dictionary of the subreddit’s current settings.
-
spam
(only=None, **generator_kwargs)¶ 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
¶ 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("Mod: {}, Subreddit: {}".format(log.mod, log.subreddit))
-
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)
-
unread
(**generator_kwargs)¶ Return a
ListingGenerator
for unread moderator messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.See
inbox
for all messages.To print the mail in the unread modmail queue try:
for message in reddit.subreddit('mod').mod.unread(): print("From: {}, To: {}".format(message.author, message.dest))
-
update
(**settings)¶ Update the subreddit’s settings.
Parameters: - allow_images – Allow users to upload images using the native image hosting. Only applies to link-only subreddits.
- 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. - 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.
- description – Shown in the sidebar of your subreddit.
- disable_contributor_requests (bool) – Specifies whether redditors may send automated modmail messages requesting approval as a submitter.
- domain – Domain name with a cname that points to {subreddit}.reddit.com.
- exclude_banned_modqueue – Exclude posts by site-wide banned users from modqueue/unmoderated.
- 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
,self
. - 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 (bool) – Specifies whether approved users have the ability to comment.
- restrict_posting (bool) – 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.
- sr – The fullname of the subreddit whose settings will be updated.
- 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
,new
,old
,qa
,random
,top
. - title – The title of the subreddit.
- 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
,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.
-