import { whopApi } from "@/lib/whop-api";

const result = await whopApi.messages.listMessagesFromChat({
	// The ID of the experience to fetch posts from
	chatExperienceId: "exp_XXXXXXXX",
});

Example output:

const response = {
	// List of posts
	posts: [
		{
			// 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 message
			content: "some string",

			// The rich content of the message
			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 message has been edited
			isEdited: true,

			// Whether this message is pinned
			isPinned: true,

			// Whether everyone was mentioned in this message
			isEveryoneMentioned: true,

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

			// The type of post
			messageType: "automated" /* Valid values: automated | regular | system */,

			// The ID of the message this is replying to, if applicable
			replyingToPostId: "xxxxxxxxxxx",

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

			// The user who sent this message
			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",
			},
		},
	],
};