You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6aad387
Browse filesBrowse the repository at this point in the historyBrowse files
Community Highlights display selected posts at the top of a subreddit. Use `post.isHighlighted()`, `post.highlight()`, and `post.unhighlight()` to inspect or change a post's highlight. Use the subreddit methods to retrieve the highlighted posts and change their display order.
139
+
140
+
These operations use the app's Reddit access. If you expose them through an app endpoint, check that the current user has permission to manage the subreddit's posts.
141
+
142
+
This example checks the caller's moderator permissions, highlights the current post for seven days, and moves it to the first position:
`post.highlight()` updates the settings if the post is already highlighted. Omit `highlightUntil` to keep a highlight until it is removed. A subreddit can have six highlights; highlighting a seventh post removes the last highlight in display order.
190
+
191
+
To remove a highlight, call `await post.unhighlight()` from an authorized action. Removing a highlight from a post that is not highlighted has no effect. These methods do not accept `runAs`.
192
+
193
+
`subreddit.getHighlightedPosts()` returns an ordered array of [HighlightedPostInfo](../../api/redditapi/models/type-aliases/HighlightedPostInfo.md), rather than `Post` objects. Each item has a `postId` and optional `highlightedUntil` and `highlightLabel` fields. Use `reddit.getPostById(postId)` when you need the post's content. Note the different names for the input options: `highlightUntil` and `highlightLabelType`.
194
+
195
+
Fetch the current highlights before reordering and pass the complete intended order. Another moderator can change the list between requests, so handle failures and refresh the list before trying again.
196
+
197
+
See the [Post highlight methods](../../api/redditapi/models/classes/Post.md#highlight), [HighlightPostOptions](../../api/redditapi/models/type-aliases/HighlightPostOptions.md), and [Subreddit reorder method](../../api/redditapi/models/classes/Subreddit.md#reorderhighlightedposts) for the API references.
Community Highlights display selected posts at the top of a subreddit. Use `post.isHighlighted()`, `post.highlight()`, and `post.unhighlight()` to inspect or change a post's highlight. Use the subreddit methods to retrieve the highlighted posts and change their display order.
139
+
140
+
These operations use the app's Reddit access. If you expose them through an app endpoint, check that the current user has permission to manage the subreddit's posts.
141
+
142
+
This example checks the caller's moderator permissions, highlights the current post for seven days, and moves it to the first position:
`post.highlight()` updates the settings if the post is already highlighted. Omit `highlightUntil` to keep a highlight until it is removed. A subreddit can have six highlights; highlighting a seventh post removes the last highlight in display order.
190
+
191
+
To remove a highlight, call `await post.unhighlight()` from an authorized action. Removing a highlight from a post that is not highlighted has no effect. These methods do not accept `runAs`.
192
+
193
+
`subreddit.getHighlightedPosts()` returns an ordered array of [HighlightedPostInfo](../../api/redditapi/models/type-aliases/HighlightedPostInfo.md), rather than `Post` objects. Each item has a `postId` and optional `highlightedUntil` and `highlightLabel` fields. Use `reddit.getPostById(postId)` when you need the post's content. Note the different names for the input options: `highlightUntil` and `highlightLabelType`.
194
+
195
+
Fetch the current highlights before reordering and pass the complete intended order. Another moderator can change the list between requests, so handle failures and refresh the list before trying again.
196
+
197
+
See the [Post highlight methods](../../api/redditapi/models/classes/Post.md#highlight), [HighlightPostOptions](../../api/redditapi/models/type-aliases/HighlightPostOptions.md), and [Subreddit reorder method](../../api/redditapi/models/classes/Subreddit.md#reorderhighlightedposts) for the API references.
0 commit comments