WikiPageModeration
- class asyncpraw.models.reddit.wikipage.WikiPageModeration(wikipage: WikiPage)
Provides a set of moderation functions for a
WikiPage
.For example, to add
spez
as an editor on the wikipagepraw_test
try:subreddit = await reddit.subreddit("test") page = await subreddit.wiki.get_page("praw_test") await page.mod.add("spez")
- __init__(wikipage: WikiPage)
Initialize a
WikiPageModeration
instance.- Parameters:
wikipage – The wikipage to moderate.
- await add(redditor: asyncpraw.models.Redditor)
Add an editor to this
WikiPage
.- Parameters:
redditor – A redditor name or
Redditor
instance.
To add u/spez as an editor on the wikipage
"praw_test"
try:subreddit = await reddit.subreddit("test") page = await subreddit.wiki.get_page("praw_test", fetch=False) await page.mod.add("spez")
- await remove(redditor: asyncpraw.models.Redditor)
Remove an editor from this
WikiPage
.- Parameters:
redditor – A redditor name or
Redditor
instance.
To remove u/spez as an editor on the wikipage
"praw_test"
try:subreddit = await reddit.subreddit("test") page = await subreddit.wiki.get_page("praw_test", fetch=False) await page.mod.remove("spez")
- await revert()
Revert a wikipage back to a specific revision.
To revert the page
"praw_test"
in r/test to revision"1234abc"
, trysubreddit = await reddit.subreddit("test") wikipage = await subreddit.wiki.get_page("praw_test") revision = await wikipage.revision("1234abc") await revision.mod.revert()
Note
When you attempt to revert the page
config/stylesheet
, Reddit checks to see if the revision being reverted to passes the CSS filter. If the check fails, then the revision attempt will also fail, and aasyncprawcore.Forbidden
exception will be raised. For example, you can’t revert to a revision that contains a link tourl(%%PRAW%%)
if there is no image namedPRAW
on the current stylesheet.Here is an example of how to look for this type of error:
from asyncprawcore.exceptions import Forbidden try: subreddit = await reddit.subreddit("test") wikipage = await subreddit.wiki.get_page("config/stylesheet") revision = await wikipage.revision("1234abc") await revision.mod.revert() except Forbidden as exception: try: await exception.response.json() except ValueError: exception.response.text
If the error occurs, the output will look something like
{"reason": "INVALID_CSS", "message": "Forbidden", "explanation": "%(css_error)s"}
- await update(*, listed: bool, permlevel: int, **other_settings: Any) Dict[str, Any]
Update the settings for this
WikiPage
.- Parameters:
listed – Show this page on page list.
permlevel – Who can edit this page?
0
use subreddit wiki permissions,1
only approved wiki contributors for this page may edit (seeWikiPageModeration.add()
),2
only mods may edit and view.other_settings – Additional keyword arguments to pass.
- Returns:
The updated WikiPage settings.
To set the wikipage
praw_test
in r/test to mod only and disable it from showing in the page list, try:subreddit = await reddit.subreddit("test") page = await subreddit.wiki.get_page("praw_test", fetch=False) await page.mod.update(listed=False, permlevel=2)