Skip to main content

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 }, or null. 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 change Party.current() or the launch party used by Multiplayer.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. role is member, host or owner.
  • 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 }. body is the Castle chat JSON; text is 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 stored PartyMessage.
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!");
}