This operation is only available on the server.
import { whopApi } from "@/lib/whop-api";

const result = await whopApi.forums.createForumPost({
	// The access pass (whop) to create this post in (leave empty if providing a
	// forum experience ID). This will look like prod_xxxx.
	accessPassId: "prod_XXXXXXXX",

	// The attachments for this post, such as videos or images.
	attachments: [
		{
			// This ID should be used the first time you upload an attachment. It is the ID
			// of the direct upload that was created when uploading the file to S3 via the
			// mediaDirectUpload mutation.
			directUploadId: "xxxxxxxxxxx",

			// The ID of an existing attachment object. Use this when updating a resource and
			// keeping a subset of the attachments. Don't use this unless you know what you're doing.
			id: "xxxxxxxxxxx",
		},
	],

	// The content of the post. This is the main body of the post. Hidden if paywalled.
	content: "some string" /* Required! */,

	// The ID of the forum experience to send the message in. (leave empty if
	// creating a new experience). This will look like exp_xxxx.
	forumExperienceId: "some string",

	// This is used to determine if the post should be sent as a 'mention'
	// notification to all of the users who are in the experience. This means that
	// anyone with 'mentions' enabled will receive a notification about this post.
	isMention: true,

	// The ID of the parent post, if applicable (Used when making a comment)
	parentId: "post_XXXXXXXX",

	// The amount to paywall this post by. A paywalled post requires the user to purchase it in order to view its content.
	paywallAmount: 10,

	// The currency to paywall this post by. A paywalled post requires the user to purchase it in order to view its content.
	paywallCurrency:
		"aed" /* Valid values: aed | all | amd | ape | ars | aud | bam | bgn | bhd | bob | brl | bsd | cad | chf | clp | cop | crc | czk | dkk | dop | dzd | egp | etb | eth | eur | gbp | ghs | gmd | gtq | gyd | hkd | huf | idr | ils | inr | jmd | jod | jpy | kes | khr | krw | kwd | lkr | mad | mdl | mga | mkd | mnt | mop | mur | mxn | myr | nad | ngn | nok | nzd | omr | pen | php | pkr | pln | pyg | qar | ron | rsd | rub | rwf | sar | sek | sgd | thb | tnd | try | ttd | twd | tzs | usd | uyu | uzs | vnd | xcd | xof | zar */,

	// Whether the post should be pinned
	pinned: true,

	// The poll for this post. A poll lets you collect responses to a multiple choice question.
	poll: {
		// The options for the poll. Must have sequential IDs starting from 1
		options: [
			{
				// Sequential ID for the poll option (starting from '1')
				id: "some string" /* Required! */,

				// The text of the poll option
				text: "some string" /* Required! */,
			},
		] /* Required! */,
	},

	// The title of the post. Visible if paywalled.
	title: "some string",
});

Example output:

const response = {
	// The unique identifier for the entity
	id: "xxxxxxxxxxx",

	// The time the entity was created (in milliseconds since Unix epoch)
	createdAt: "9999999",

	// The time the entity was last updated (in milliseconds since Unix epoch)
	updatedAt: "9999999",

	// The text content of the forum post
	content: "some string",

	// The rich content of the forum post
	richContent: "some string",

	// Whether the entity has been deleted
	isDeleted: true,

	// The attachments to this message
	attachments: [
		{
			// The ID of the attachment
			id: "xxxxxxxxxxx",

			// The attachment's content type (e.g., image/jpg, video/mp4)
			contentType: "some string",

			// The original URL of the attachment, such as a direct link to S3. This should
			// never be displayed on the client and always passed to an Imgproxy transformer.
			sourceUrl: "some string",
		},
	],

	// Whether the forum post has been edited
	isEdited: true,

	// Whether this forum post is pinned
	isPinned: true,

	// The IDs of the users mentioned in this forum post
	mentionedUserIds: ["xxxxxxxxxxx"],

	// The ID of the parent forum post, if applicable
	parentId: "xxxxxxxxxxx",

	// The number of times this message has been viewed
	viewCount: 10,

	// The user who created this forum post
	user: {
		// The internal ID of the user.
		id: "xxxxxxxxxxx",

		// The name of the user from their Whop account.
		name: "some string",

		// The username of the user from their Whop account.
		username: "some string",

		// The user's profile picture
		profilePicture: {
			// The original URL of the attachment, such as a direct link to S3. This should
			// never be displayed on the client and always passed to an Imgproxy transformer.
			sourceUrl: "some string",
		},

		// Whether or not the user's phone is verified
		phoneVerified: true,

		// The city the user is from.
		city: "some string",

		// The country the user is from.
		country: "some string",
	},
};