SubmissionModeration¶
- class asyncpraw.models.reddit.submission.SubmissionModeration(submission)¶
Provide a set of functions pertaining to
Submissionmoderation.Example usage:
submission = await reddit.submission("8dmv8z", fetch=False) await submission.mod.approve()
- Parameters:
submission (asyncpraw.models.Submission)
- __init__(submission)¶
Initialize a
SubmissionModerationinstance.- Parameters:
submission (
Submission) – The submission to moderate.- Return type:
None
- await approve()¶
Approve a
CommentorSubmission.Approving a comment or submission reverts a removal, resets the report counter, adds a green check mark indicator (only visible to other moderators) on the website view, and sets the
approved_byattribute to the authenticated user.Example usage:
# approve a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.approve() # approve a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.approve()
- Return type:
- author_notes(**generator_kwargs)¶
Get the moderator notes for the author of this object in the subreddit it’s posted in.
- Parameters:
generator_kwargs (
Any) – Additional keyword arguments are passed in the initialization of the moderator note generator.- Return type:
- Returns:
A generator of
ModNote.
For example, to list all notes the author of a submission, try:
for note in reddit.submission("92dd8").mod.author_notes(): print(f"{note.label}: {note.note}")
- await contest_mode(*, state=True)¶
Set contest mode for the comments of this submission.
- Parameters:
state (
bool) –Trueenables contest mode andFalsedisables (default:True).- Return type:
Contest mode have the following effects:
The comment thread will default to being sorted randomly.
Replies to top-level comments will be hidden behind “[show replies]” buttons.
Scores will be hidden from non-moderators.
Scores accessed through the API (mobile apps, bots) will be obscured to “1” for non-moderators.
Example usage:
submission = await reddit.submission("5or86n", fetch=False) await submission.mod.contest_mode()
- await create_note(*, label=None, note, **other_settings)¶
Create a moderator note on the author of this object in the subreddit it’s posted in.
- Parameters:
label (
str|None) – The label for the note. As of this writing, this can be one of the following:"ABUSE_WARNING","BAN","BOT_BAN","HELPFUL_USER","PERMA_BAN","SOLID_CONTRIBUTOR","SPAM_WARNING","SPAM_WATCH", orNone(default:None).note (
str) – The content of the note. As of this writing, this is limited to 250 characters.other_settings (
Any) – Additional keyword arguments are passed tocreate().
- Return type:
- Returns:
The new
ModNoteobject.
For example, to create a note on a
Submission, try:submission = await reddit.submission("92dd8") await submission.mod.create_note(label="HELPFUL_USER", note="Test note")
- await distinguish(*, how='yes', sticky=False)¶
Distinguish a
CommentorSubmission.- Parameters:
how (
str) – One of"yes","no","admin", or"special"."yes"adds a moderator level distinguish."no"removes any distinction."admin"and"special"require special user privileges to use (default"yes").sticky (
bool) –Commentis stickied ifTrue, placing it at the top of the comment page regardless of score. If thing is not a top-level comment, this parameter is silently ignored (defaultFalse).
- Return type:
Example usage:
# distinguish and sticky a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.distinguish(sticky=True) # undistinguish a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.distinguish(how="no")
See also
- await flair(*, css_class='', flair_template_id=None, text='')¶
Set flair for the submission.
- Parameters:
css_class (
str) – The css class to associate with the flair html (default:"").flair_template_id (
str|None) – The flair template ID to use when flairing.text (
str) – The flair text to associate with theSubmission(default:"").
- Return type:
This method can only be used by an authenticated user who is a moderator of the submission’s
Subreddit.Example usage:
submission = await reddit.submission("5or86n", fetch=False) await submission.mod.flair(text="PRAW", css_class="bot")
- await ignore_reports()¶
Ignore future reports on a
CommentorSubmission.Calling this method will prevent future reports on this
CommentorSubmissionfrom both triggering notifications and appearing in the various moderation listings. The report count will still increment on theCommentorSubmission.Example usage:
# ignore future reports on a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.ignore_reports() # ignore future reports on a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.ignore_reports()
See also
- Return type:
- await lock()¶
Lock a
CommentorSubmission.Example usage:
# lock a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.lock() # lock a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.lock()
See also
- Return type:
- await nsfw()¶
Mark as not safe for work.
This method can be used both by the submission author and moderators of the subreddit that the submission belongs to.
Example usage:
subreddit = await reddit.subreddit("test") submission = await subreddit.submit("nsfw test", selftext="nsfw") await submission.mod.nsfw()
See also
- Return type:
- await remove(*, mod_note='', spam=False, reason_id=None)¶
Remove a
CommentorSubmission.- Parameters:
- Return type:
If either
reason_idormod_noteare provided, a second API call is made to add the removal reason.Example usage:
# remove a comment and mark as spam: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.remove(spam=True) # remove a submission submission = await reddit.submission("5or86n", fetch=False) await submission.mod.remove() # remove a submission with a removal reason sub = await reddit.subreddit("test") reason = await sub.mod.removal_reasons.get_reason("110ni21zo23ql") submission = await reddit.submission("5or86n", fetch=False) await submission.mod.remove(reason_id=reason.id)
- await send_removal_message(*, message, title='ignored', type='public')¶
Send a removal message for a
CommentorSubmission.Warning
The object has to be removed before giving it a removal reason. Remove the object with
remove(). Trying to add a removal reason without removing the object will result inRedditAPIExceptionbeing thrown with anINVALID_IDerror_type.Reddit adds human-readable information about the object to the message.
- Parameters:
type (
str) – One of"public","private", or"private_exposed"."public"leaves a stickied comment on the post."private"sends a modmail message with hidden username."private_exposed"sends a modmail message without hidden username (default:"public").title (
str) – The short reason given in the message. Ignored if type is"public".message (
str) – The body of the message.
- Return type:
- Returns:
The new
Commentiftypeis"public".
- await set_original_content()¶
Mark as original content.
This method can be used by moderators of the subreddit that the submission belongs to. If the subreddit has enabled the Original Content beta feature in settings, then the submission’s author can use it as well.
Example usage:
subreddit = await reddit.subreddit("test") submission = await subreddit.submit("oc test", selftext="original") await submission.mod.set_original_content()
See also
- Return type:
- await sfw()¶
Mark as safe for work.
This method can be used both by the submission author and moderators of the subreddit that the submission belongs to.
Example usage:
submission = await reddit.submission("5or86n", fetch=False) await submission.mod.sfw()
See also
- Return type:
- await spoiler()¶
Indicate that the submission contains spoilers.
This method can be used both by the submission author and moderators of the subreddit that the submission belongs to.
Example usage:
submission = await reddit.submission("5or86n", fetch=False) await submission.mod.spoiler()
See also
- Return type:
- await sticky(*, bottom=True, state=True)¶
Set the submission’s sticky state in its subreddit.
- Parameters:
- Return type:
- Returns:
The stickied submission object.
Note
When a submission is stickied two or more times, the Reddit API responds with a 409 error that is raised as a
Conflictby asyncprawcore. This method suppresses theseConflicterrors.This submission will replace the second stickied submission if one exists.
For example:
submission = await reddit.submission("5or86n", fetch=False) await submission.mod.sticky()
- await suggested_sort(*, sort='blank')¶
Set the suggested sort for the comments of the submission.
- await undistinguish()¶
Remove mod, admin, or special distinguishing from an object.
Also unstickies the object if applicable.
Example usage:
# undistinguish a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.undistinguish() # undistinguish a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.undistinguish()
See also
- Return type:
- await unignore_reports()¶
Resume receiving future reports on a
CommentorSubmission.Future reports on this
CommentorSubmissionwill cause notifications, and appear in the various moderation listings.Example usage:
# accept future reports on a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.unignore_reports() # accept future reports on a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.unignore_reports()
See also
- Return type:
- await unlock()¶
Unlock a
CommentorSubmission.Example usage:
# unlock a comment: comment = await reddit.comment("dkk4qjd", fetch=False) await comment.mod.unlock() # unlock a submission: submission = await reddit.submission("5or86n", fetch=False) await submission.mod.unlock()
See also
- Return type:
- await unset_original_content()¶
Indicate that the submission is not original content.
This method can be used by moderators of the subreddit that the submission belongs to. If the subreddit has enabled the Original Content beta feature in settings, then the submission’s author can use it as well.
Example usage:
subreddit = await reddit.subreddit("test") submission = await subreddit.submit("oc test", selftext="original") await submission.mod.unset_original_content()
See also
- Return type:
- await unspoiler()¶
Indicate that the submission does not contain spoilers.
This method can be used both by the submission author and moderators of the subreddit that the submission belongs to.
For example:
sub = await reddit.subreddit("test") submission = await sub.submit("not spoiler", selftext="spoiler") await submission.mod.unspoiler()
See also
- Return type:
- await update_crowd_control_level(level)¶
Change the Crowd Control level of the submission.
Level Descriptions
Level
Name
Description
0
Off
Crowd Control will not action any of the submission’s comments.
1
Lenient
Comments from users who have negative karma in the subreddit are automatically collapsed.
2
Moderate
Comments from new users and users with negative karma in the subreddit are automatically collapsed.
3
Strict
Comments from users who haven’t joined the subreddit, new users, and users with negative karma in the subreddit are automatically collapsed.
Example usage:
submission = await reddit.submission("745ryj") await submission.mod.update_crowd_control_level(2)
See also