From 0731e938d32d14468ddbdff32323e2327936f0f7 Mon Sep 17 00:00:00 2001 From: Xenc5 Date: Tue, 30 Jun 2026 00:10:44 +0100 Subject: [PATCH] Update code snippets to 0.13.4 --- docs/capabilities/creating_custom_post.md | 6 ++---- docs/capabilities/server/reddit-api.mdx | 11 +++-------- docs/capabilities/server/userActions.mdx | 10 +++++----- docs/guides/migrate/public-api.md | 2 +- .../version-0.12/capabilities/creating_custom_post.md | 6 ++---- .../version-0.12/capabilities/server/reddit-api.mdx | 11 +++-------- .../version-0.12/capabilities/server/userActions.mdx | 10 +++++----- .../version-0.12/guides/migrate/public-api.md | 2 +- .../version-0.13/capabilities/creating_custom_post.md | 6 ++---- .../version-0.13/capabilities/server/reddit-api.mdx | 11 +++-------- .../version-0.13/capabilities/server/userActions.mdx | 10 +++++----- .../version-0.13/guides/migrate/public-api.md | 2 +- 12 files changed, 33 insertions(+), 54 deletions(-) diff --git a/docs/capabilities/creating_custom_post.md b/docs/capabilities/creating_custom_post.md index 66ef675b..2768d612 100644 --- a/docs/capabilities/creating_custom_post.md +++ b/docs/capabilities/creating_custom_post.md @@ -76,7 +76,7 @@ await reddit.submitCustomPost({ "backgroundColor": "#FFFFFFFF", // white, fully opaque "backgroundColorDark": "#000000FF", // black, fully opaque "height": "TALL", - "shareImageUrl": "https://reddi.it/12345.png" + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" } }) ``` @@ -90,9 +90,7 @@ Use `post.setCustomPostStyles()` to update styles on an existing post. Only inc ```javascript const post = await reddit.getPostById(context.postId); await post.setCustomPostStyles({ - "styles": { - "shareImageUrl": "https://example.com/new-preview.png" - } + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" }); ``` diff --git a/docs/capabilities/server/reddit-api.mdx b/docs/capabilities/server/reddit-api.mdx index a2b32781..b18db25f 100644 --- a/docs/capabilities/server/reddit-api.mdx +++ b/docs/capabilities/server/reddit-api.mdx @@ -90,16 +90,11 @@ Auto-comments should be used to spark conversation in the post comments, but you ```ts -import { context, reddit } from '@devvit/web/server'; +import { reddit } from '@devvit/web/server'; export const createComment = async () => { - const { subredditName } = context; - if (!subredditName) { - throw new Error('subredditName is required'); - } - - reddit.submitComment({ - postId: 't3_123456', // Replace with the actual post ID + return await reddit.submitComment({ + id: 't3_123456', // Replace with the actual post ID text: 'This is a comment from a Devvit app', runAs: 'USER' // Optional: specify the user to run as }); diff --git a/docs/capabilities/server/userActions.mdx b/docs/capabilities/server/userActions.mdx index e31ec218..a3f97017 100644 --- a/docs/capabilities/server/userActions.mdx +++ b/docs/capabilities/server/userActions.mdx @@ -69,7 +69,7 @@ If `runAs` is not specified, the API will use `runAs: 'APP'` by default. | Parameter | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | | `runAs` | The type of account to perform the action on behalf of: `'USER'` or `'APP'`. Defaults to `'APP'`. | -| `userGeneratedContent` | Text or images submitted by the user. Required for `submitPost()` with `runAs: 'USER'` for safety and compliance review. | +| `userGeneratedContent` | Text or images submitted by the user. Required for `submitCustomPost()` with `runAs: 'USER'` for safety and compliance review. | ### Differences during playtesting @@ -96,7 +96,7 @@ Your app version needs to be approved in order for user actions to be enabled fo ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -106,7 +106,7 @@ app.post('/internal/post-create', async (c) => { return c.json({ status: 'error', message: 'subredditName is required' }, 400); } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", @@ -124,7 +124,7 @@ app.post('/internal/post-create', async (c) => { ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -135,7 +135,7 @@ router.post('/internal/post-create', async (_req, res) => { return; } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", diff --git a/docs/guides/migrate/public-api.md b/docs/guides/migrate/public-api.md index 1ae78ab3..83520cc7 100644 --- a/docs/guides/migrate/public-api.md +++ b/docs/guides/migrate/public-api.md @@ -312,7 +312,7 @@ const { postId } = context; if (!postId) throw new Error("Run on a post."); const pinned = await reddit.submitComment({ - postId, + id: postId, text: "Pinned notice.", runAs: "APP", }); diff --git a/versioned_docs/version-0.12/capabilities/creating_custom_post.md b/versioned_docs/version-0.12/capabilities/creating_custom_post.md index 66ef675b..2768d612 100644 --- a/versioned_docs/version-0.12/capabilities/creating_custom_post.md +++ b/versioned_docs/version-0.12/capabilities/creating_custom_post.md @@ -76,7 +76,7 @@ await reddit.submitCustomPost({ "backgroundColor": "#FFFFFFFF", // white, fully opaque "backgroundColorDark": "#000000FF", // black, fully opaque "height": "TALL", - "shareImageUrl": "https://reddi.it/12345.png" + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" } }) ``` @@ -90,9 +90,7 @@ Use `post.setCustomPostStyles()` to update styles on an existing post. Only inc ```javascript const post = await reddit.getPostById(context.postId); await post.setCustomPostStyles({ - "styles": { - "shareImageUrl": "https://example.com/new-preview.png" - } + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" }); ``` diff --git a/versioned_docs/version-0.12/capabilities/server/reddit-api.mdx b/versioned_docs/version-0.12/capabilities/server/reddit-api.mdx index a2b32781..b18db25f 100644 --- a/versioned_docs/version-0.12/capabilities/server/reddit-api.mdx +++ b/versioned_docs/version-0.12/capabilities/server/reddit-api.mdx @@ -90,16 +90,11 @@ Auto-comments should be used to spark conversation in the post comments, but you ```ts -import { context, reddit } from '@devvit/web/server'; +import { reddit } from '@devvit/web/server'; export const createComment = async () => { - const { subredditName } = context; - if (!subredditName) { - throw new Error('subredditName is required'); - } - - reddit.submitComment({ - postId: 't3_123456', // Replace with the actual post ID + return await reddit.submitComment({ + id: 't3_123456', // Replace with the actual post ID text: 'This is a comment from a Devvit app', runAs: 'USER' // Optional: specify the user to run as }); diff --git a/versioned_docs/version-0.12/capabilities/server/userActions.mdx b/versioned_docs/version-0.12/capabilities/server/userActions.mdx index e31ec218..a3f97017 100644 --- a/versioned_docs/version-0.12/capabilities/server/userActions.mdx +++ b/versioned_docs/version-0.12/capabilities/server/userActions.mdx @@ -69,7 +69,7 @@ If `runAs` is not specified, the API will use `runAs: 'APP'` by default. | Parameter | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | | `runAs` | The type of account to perform the action on behalf of: `'USER'` or `'APP'`. Defaults to `'APP'`. | -| `userGeneratedContent` | Text or images submitted by the user. Required for `submitPost()` with `runAs: 'USER'` for safety and compliance review. | +| `userGeneratedContent` | Text or images submitted by the user. Required for `submitCustomPost()` with `runAs: 'USER'` for safety and compliance review. | ### Differences during playtesting @@ -96,7 +96,7 @@ Your app version needs to be approved in order for user actions to be enabled fo ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -106,7 +106,7 @@ app.post('/internal/post-create', async (c) => { return c.json({ status: 'error', message: 'subredditName is required' }, 400); } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", @@ -124,7 +124,7 @@ app.post('/internal/post-create', async (c) => { ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -135,7 +135,7 @@ router.post('/internal/post-create', async (_req, res) => { return; } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", diff --git a/versioned_docs/version-0.12/guides/migrate/public-api.md b/versioned_docs/version-0.12/guides/migrate/public-api.md index 1ae78ab3..83520cc7 100644 --- a/versioned_docs/version-0.12/guides/migrate/public-api.md +++ b/versioned_docs/version-0.12/guides/migrate/public-api.md @@ -312,7 +312,7 @@ const { postId } = context; if (!postId) throw new Error("Run on a post."); const pinned = await reddit.submitComment({ - postId, + id: postId, text: "Pinned notice.", runAs: "APP", }); diff --git a/versioned_docs/version-0.13/capabilities/creating_custom_post.md b/versioned_docs/version-0.13/capabilities/creating_custom_post.md index 66ef675b..2768d612 100644 --- a/versioned_docs/version-0.13/capabilities/creating_custom_post.md +++ b/versioned_docs/version-0.13/capabilities/creating_custom_post.md @@ -76,7 +76,7 @@ await reddit.submitCustomPost({ "backgroundColor": "#FFFFFFFF", // white, fully opaque "backgroundColorDark": "#000000FF", // black, fully opaque "height": "TALL", - "shareImageUrl": "https://reddi.it/12345.png" + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" } }) ``` @@ -90,9 +90,7 @@ Use `post.setCustomPostStyles()` to update styles on an existing post. Only inc ```javascript const post = await reddit.getPostById(context.postId); await post.setCustomPostStyles({ - "styles": { - "shareImageUrl": "https://example.com/new-preview.png" - } + "shareImageUrl": "https://i.redd.it/o0h58lzmax6a1.png" }); ``` diff --git a/versioned_docs/version-0.13/capabilities/server/reddit-api.mdx b/versioned_docs/version-0.13/capabilities/server/reddit-api.mdx index a2b32781..b18db25f 100644 --- a/versioned_docs/version-0.13/capabilities/server/reddit-api.mdx +++ b/versioned_docs/version-0.13/capabilities/server/reddit-api.mdx @@ -90,16 +90,11 @@ Auto-comments should be used to spark conversation in the post comments, but you ```ts -import { context, reddit } from '@devvit/web/server'; +import { reddit } from '@devvit/web/server'; export const createComment = async () => { - const { subredditName } = context; - if (!subredditName) { - throw new Error('subredditName is required'); - } - - reddit.submitComment({ - postId: 't3_123456', // Replace with the actual post ID + return await reddit.submitComment({ + id: 't3_123456', // Replace with the actual post ID text: 'This is a comment from a Devvit app', runAs: 'USER' // Optional: specify the user to run as }); diff --git a/versioned_docs/version-0.13/capabilities/server/userActions.mdx b/versioned_docs/version-0.13/capabilities/server/userActions.mdx index e31ec218..a3f97017 100644 --- a/versioned_docs/version-0.13/capabilities/server/userActions.mdx +++ b/versioned_docs/version-0.13/capabilities/server/userActions.mdx @@ -69,7 +69,7 @@ If `runAs` is not specified, the API will use `runAs: 'APP'` by default. | Parameter | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | | `runAs` | The type of account to perform the action on behalf of: `'USER'` or `'APP'`. Defaults to `'APP'`. | -| `userGeneratedContent` | Text or images submitted by the user. Required for `submitPost()` with `runAs: 'USER'` for safety and compliance review. | +| `userGeneratedContent` | Text or images submitted by the user. Required for `submitCustomPost()` with `runAs: 'USER'` for safety and compliance review. | ### Differences during playtesting @@ -96,7 +96,7 @@ Your app version needs to be approved in order for user actions to be enabled fo ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -106,7 +106,7 @@ app.post('/internal/post-create', async (c) => { return c.json({ status: 'error', message: 'subredditName is required' }, 400); } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", @@ -124,7 +124,7 @@ app.post('/internal/post-create', async (c) => { ```tsx title="server/index.ts" -import { reddit } from '@devvit/web/server'; +import { context, reddit } from '@devvit/web/server'; // ... @@ -135,7 +135,7 @@ router.post('/internal/post-create', async (_req, res) => { return; } - reddit.submitPost({ + await reddit.submitCustomPost({ runAs: 'USER', userGeneratedContent: { text: "Hello there! This is a new post from the user's account", diff --git a/versioned_docs/version-0.13/guides/migrate/public-api.md b/versioned_docs/version-0.13/guides/migrate/public-api.md index 1ae78ab3..83520cc7 100644 --- a/versioned_docs/version-0.13/guides/migrate/public-api.md +++ b/versioned_docs/version-0.13/guides/migrate/public-api.md @@ -312,7 +312,7 @@ const { postId } = context; if (!postId) throw new Error("Run on a post."); const pinned = await reddit.submitComment({ - postId, + id: postId, text: "Pinned notice.", runAs: "APP", });