new WikiPage()
Example
// Get a wiki page on a given subreddit by name r.getSubreddit('AskReddit').getWikiPage('rules')
Extends
Methods
-
getSettings()
Gets the current settings for this wiki page.
-
Returns:
An Object representing the settings for this page
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').getSettings().then(console.log) // => WikiPageSettings { permlevel: 0, editors: [], listed: true }
-
editSettings(options)
Edits the settings for this wiki page.
-
Parameters:
Name Type Description options
object Properties
Name Type Description listed
boolean Determines whether this wiki page should appear on the public list of pages for this subreddit.
permissionLevel
number Determines who should be allowed to access and edit this page
0
indicates that this subreddit's default wiki settings should get used,1
indicates that only approved wiki contributors on this subreddit should be able to edit this page, and2
indicates that only mods should be able to view and edit this page.Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').editSettings({listed: false, permission_level: 1})
-
addEditor(options)
Makes the given user an approved editor of this wiki page.
-
Parameters:
Name Type Description options
object Properties
Name Type Description name
string The name of the user to be added
Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').addEditor({name: 'actually_an_aardvark'})
-
removeEditor(options)
Revokes this user's approved editor status for this wiki page
-
Parameters:
Name Type Description options
object Properties
Name Type Description name
string The name of the user to be removed
Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').removeEditor({name: 'actually_an_aardvark'})
-
edit(options)
Edits this wiki page, or creates it if it does not exist yet.
-
Parameters:
Name Type Description options
object Properties
Name Type Argument Description text
string The new content of the page, in markdown.
reason
string <optional>
The edit reason that will appear in this page's revision history. 256 characters max
previousRevision
string <optional>
Determines which revision this edit should be added to. If this parameter is omitted, this edit is simply added to the most recent revision.
Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').edit({text: 'Welcome', reason: 'Added a welcome message'})
-
getRevisions( [options])
Gets a list of revisions for this wiki page.
-
Parameters:
Name Type Argument Description options
object <optional>
Options for the resulting Listing
Returns:
A Listing containing revisions of this page
- Type
- Promise
Example
r.getSubreddit('snoowrap').getRevisions({limit: 1}).then(console.log) // => Listing [ // { // timestamp: 1460973194, // reason: 'Added a welcome message', // author: RedditUser { name: 'not_an_aardvark', id: 'k83md', ... }, // page: 'index', // id: '506370b4-0508-11e6-b550-0e69f29e0c4d' // } // ]
-
hideRevision(options)
Hides the given revision from this page's public revision history.
-
Parameters:
Name Type Description options
object Properties
Name Type Description id
string The revision's id
Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').hideRevision({id: '506370b4-0508-11e6-b550-0e69f29e0c4d'})
-
revert(options)
Reverts this wiki page to the given point.
-
Parameters:
Name Type Description options
object Properties
Name Type Description id
string The id of the revision that this page should be reverted to
Returns:
A Promise that fulfills with this WikiPage when the request is complete
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').revert({id: '506370b4-0508-11e6-b550-0e69f29e0c4d'})
-
getDiscussions( [options])
Gets a list of discussions about this wiki page.
-
Parameters:
Name Type Argument Description options
object <optional>
Options for the resulting Listing
Returns:
A Listing containing discussions about this page
- Type
- Promise
Example
r.getSubreddit('snoowrap').getWikiPage('index').getDiscussions().then(console.log) // => Listing [ // Submission { ... }, // Submission { ... }, // ... // ]
-
fetch()
Fetches this content from reddit.
-
This will not mutate the original content object; all Promise properties will remain as Promises after the content has been fetched. However, the information on this object will be cached, so it may become out-of-date with the content on reddit. To clear the cache and fetch this object from reddit again, use
refresh()
.If snoowrap is running in an environment that supports ES2015 Proxies (e.g. Chrome 49+), then
fetch()
will get automatically called when an unknown property is accessed on an unfetched content object.- Inherited From:
Returns:
A version of this object with all of its fetched properties from reddit. This will not mutate the object. Once an object has been fetched once, its properties will be cached, so they might end up out-of-date if this function is called again. To refresh an object, use refresh().
- Type
- Promise
Example
r.getUser('not_an_aardvark').fetch().then(userInfo => { console.log(userInfo.name); // 'not_an_aardvark' console.log(userInfo.created_utc); // 1419104352 }); r.getComment('d1xchqn').fetch().then(comment => comment.body).then(console.log) // => 'This is a little too interesting for my liking' // In environments that support ES2015 Proxies, the above line is equivalent to: r.getComment('d1xchqn').body.then(console.log); // => 'This is a little too interesting for my liking'
-
refresh()
Refreshes this content.
-
- Inherited From:
Returns:
A newly-fetched version of this content
- Type
- Promise
Example
var someComment = r.getComment('cmfkyus'); var initialCommentBody = some_comment.fetch().then(comment => comment.body); setTimeout(() => { someComment.refresh().then(refreshedComment => { if (initialCommentBody.value() !== refreshedComment.body) { console.log('This comment has changed since 10 seconds ago.'); } }); }, 10000);
-
toJSON()
Returns a stringifyable version of this object.
-
It is usually not necessary to call this method directly; simply running JSON.stringify(some_object) will strip the private properties anyway.
- Inherited From:
Returns:
A version of this object with all the private properties stripped
- Type
- object
Example
var user = r.getUser('not_an_aardvark'); JSON.stringify(user) // => '{"name":"not_an_aardvark"}'