Party
Party creates and drives Castle parties with the signed-in player's account.
Castle still enforces membership, roles, age and party permissions; refusals are
CastleErrors carrying the server's code. Party and user-id arrays are bounded
to 32 users.
Party.current()returns the party this play was launched with as{ partyId, name, status, hasUnreadMessages }, ornull. The party id comes only from trusted host context, and no request is made when the play has none.Party.create(userIds)creates a party containing those users and the signed-in player. It never sets an initial deck. Creating one does not changeParty.current()or the launch party used byMultiplayer.join({ mode: "party" }).Party.invite(partyId, userIds)invites more users.Party.respond(partyId, accept)accepts or rejects an invitation.Party.members(partyId)returns{ userId, username, photoUrl?, status, role }rows.roleismember,hostorowner.Party.leave(partyId)leaves the party.Party.messages(partyId, cursor?)returns{ messages, cursor }. Messages are newest first; pass the cursor to load older history. Each message has{ id, fromUserId, fromUsername, body, text, createdAt }.bodyis the Castle chat JSON;textis non-null only when that body is plain text with no tags, links or embeds.Party.say(partyId, text)sends plain text to the party. The host trims it and caps it at 1,000 characters, then returns the storedPartyMessage.
import { Party } from "castle-web-sdk";
const party = await Party.current();
if (party) {
const page = await Party.messages(party.partyId);
await Party.say(party.partyId, "Meet by the gate!");
}