WikiPageModeration¶
- class asyncpraw.models.reddit.wikipage.WikiPageModeration(wikipage)¶
Provides a set of moderation functions for a
WikiPage.For example, 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") await page.mod.add("spez")
- Parameters:
wikipage (WikiPage)
- __init__(wikipage)¶
Initialize a
WikiPageModerationinstance.- Parameters:
wikipage (
WikiPage) – The wikipage to moderate.- Return type:
None
- await add(redditor)¶
Add an editor to this
WikiPage.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)¶
Remove an editor from this
WikiPage.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.Forbiddenexception will be raised. For example, you can’t revert to a revision that contains a link tourl(%%PRAW%%)if there is no image namedPRAWon 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"}
- Return type:
- await update(*, listed, permlevel, **other_settings)¶
Update the settings for this
WikiPage.- Parameters:
listed (
bool) – Show this page on page list.permlevel (
int) – Who can edit this page?0use subreddit wiki permissions,1only approved wiki contributors for this page may edit (seeWikiPageModeration.add()),2only mods may edit and view.other_settings (
Any) – Additional keyword arguments to pass.
- Return type:
- 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)