WikiPageModeration

class praw.models.reddit.wikipage.WikiPageModeration(wikipage: praw.models.reddit.wikipage.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:

reddit.subreddit("test").wiki["praw_test"].mod.add("spez")
__init__(wikipage: praw.models.reddit.wikipage.WikiPage)

Initialize a WikiPageModeration instance.

Parameters

wikipage – The wikipage to moderate.

add(redditor: praw.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:

reddit.subreddit("test").wiki["praw_test"].mod.add("spez")
remove(redditor: praw.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:

reddit.subreddit("test").wiki["praw_test"].mod.remove("spez")
revert()

Revert a wikipage back to a specific revision.

To revert the page "praw_test" in r/test to revision "1234abc", try

reddit.subreddit("test").wiki["praw_test"].revision("1234abc").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 a prawcore.Forbidden exception will be raised. For example, you can’t revert to a revision that contains a link to url(%%PRAW%%) if there is no image named PRAW on the current stylesheet.

Here is an example of how to look for this type of error:

from prawcore.exceptions import Forbidden

try:
    reddit.subreddit("test").wiki["config/stylesheet"].revision("1234abc").mod.revert()
except Forbidden as exception:
    try:
        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"}
settings() Dict[str, Any]

Return the settings for this WikiPage.

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 (see WikiPageModeration.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:

reddit.subreddit("test").wiki["praw_test"].mod.update(listed=False, permlevel=2)