WikiPageModeration

class asyncpraw.models.reddit.wikipage.WikiPageModeration(wikipage: asyncpraw.models.reddit.wikipage.WikiPage)

Provides a set of moderation functions for a WikiPage.

For example, to add 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")
__init__(wikipage: asyncpraw.models.reddit.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 "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 "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", try

subreddit = 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 a asyncprawcore.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 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 settings() Dict[str, Any]

Return the settings for this WikiPage.

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 (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:

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("praw_test", fetch=False)
await page.mod.update(listed=False, permlevel=2)