Membership
phantom.aj.membershipYou and your animal
Membership.
Scripts and plugins
A script has all of it, as phantom.aj.membership, and so does a plugin, from ctx.phantom(): the SDK runs in the plugin's own frame. Each call is marked with what it needs: game:read for what the area knows and hears, which "game": "read" in the manifest grants, and game:act for doing things in it as the player, which needs "game": "act" (see Permissions).
Overview
| Member | What it does | Plugins |
|---|---|---|
hideUpsells() | Keeps the client's membership adverts off the screen until the handle is called: the advert is skipped where it starts, so nothing loads and nothing darkens. | game:act |
real() | The account's membership as Animal Jam said it, or null before the login. | game:read |
show() | Makes the player's own game show a membership until stopShowing, and resolves once the client holds it (at once before the login, which then carries it). | game:act |
showing() | The look show is making the game show, or null while it shows the real one. | game:read |
shown() | The membership the game shows now (clientInfo, userInfo.isMember); null before login. | game:read |
showUpsell() | Puts up the client's own membership advert at one of its pages (UpsellManager.displayPopup), as the game does for a non-member; '' is the "buy more diamonds" popup. | game:act |
stopShowing() | Ends show, and puts the real membership back in the game the way the client hears one redeemed, resolving once the client holds it. | game:act |
onChange() | Hears Animal Jam describe the membership: each login reply (moving servers included) and each membership redeemed in play, as the server sent them, never what show made of them. | game:read |
onShowing() | Hears show and stopShowing: the look shown now, or null once the real one is back. | game:read |
onUpsell() | Hears the client put up a membership advert (UpsellManager.displayPopup): the "join Animal Jam" popup a non-member gets on reaching for something members have. | game:read |
Methods
hideUpsells
hideUpsells(options?: ActOptions) => Promise<() => Promise<void>>Keeps the client's membership adverts off the screen until the handle is called: the advert is skipped where it starts, so nothing loads and nothing darkens. onUpsell still hears each one.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<() => Promise<void>>
Types
Example
real
real() => Promise<Membership | null>The account's membership as Animal Jam said it, or null before the login. Read from the client, or, while show is changing what the client holds, from the server's own messages.
Returns
Promise<Membership \| null>
Types
show
show(look?: Partial<MembershipLook>, options?: ActOptions) => Promise<MembershipLook>Makes the player's own game show a membership until stopShowing, and resolves once the client holds it (at once before the login, which then carries it). Calling it again changes the look. Throws a RangeError for an account type other than 2 or 3, or days outside -1 to 3650.
The look is one per game, set from wherever the player chose it, which is why it is ended by stopShowing rather than by a handle one caller would have to keep.
Parameters
| Name | Type | |
|---|---|---|
look optional | Partial<MembershipLook> | |
options optional | ActOptions |
Returns
Promise<MembershipLook>
Types
showing
showing() => Promise<MembershipLook | null>The look show is making the game show, or null while it shows the real one. From any frame on the game, not only the one that called show.
Returns
Promise<MembershipLook \| null>
Types
shown
shown() => Promise<ShownMembership | null>The membership the game shows now (clientInfo, userInfo.isMember); null before login.
Returns
Promise<ShownMembership \| null>
Types
showUpsell
showUpsell(page?: "" | "animals" | "adventures" | "dens" | "denAudio" | "pets" | "200Items" | "accessories" | "animalSlots" | "denArt" | "denItems" | "diamondShop" | "emotes" | "jamagram" | "jammerWall" | "namebars" | "oceanAnimals", options?: ActOptions & { reason?: string | undefined; }) => Promise<void>Puts up the client's own membership advert at one of its pages (UpsellManager.displayPopup), as the game does for a non-member; '' is the "buy more diamonds" popup. Nothing is sent to Animal Jam. While hideUpsells holds, the advert is skipped like any other.
Parameters
| Name | Type | |
|---|---|---|
page optional | "" | "animals" | "adventures" | "dens" | "denAudio" | "pets" | "200Items" | "accessories" | "animalSlots" | "denArt" | "denItems" | "diamondShop" | "emotes" | "jamagram" | "jammerWall" | "namebars" | "oceanAnimals" | |
options optional | ActOptions & { reason?: string | undefined; } |
Returns
Promise<void>
Types
stopShowing
stopShowing(options?: ActOptions) => Promise<void>Ends show, and puts the real membership back in the game the way the client hears one redeemed, resolving once the client holds it. Nothing happens when nothing is shown.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
Events
onChange
onChange(listener: (membership: Membership) => void) => () => voidHears Animal Jam describe the membership: each login reply (moving servers included) and each membership redeemed in play, as the server sent them, never what show made of them.
Parameters
| Name | Type | |
|---|---|---|
listener | (membership: Membership) => void |
Returns
() => void. Call it to stop listening.
Types
onShowing
onShowing(listener: (look: MembershipLook | null) => void) => () => voidHears show and stopShowing: the look shown now, or null once the real one is back. Heard in every frame on the game (from the game's own copy of the look), at once in the frame that called them; a look already shown when this starts is told on the first reading.
Parameters
| Name | Type | |
|---|---|---|
listener | (look: MembershipLook | null) => void |
Returns
() => void. Call it to stop listening.
Types
onUpsell
onUpsell(listener: (upsell: MembershipUpsell) => void) => () => voidHears the client put up a membership advert (UpsellManager.displayPopup): the "join Animal Jam" popup a non-member gets on reaching for something members have. Adverts hideUpsells keeps off the screen are heard too.
Parameters
| Name | Type | |
|---|---|---|
listener | (upsell: MembershipUpsell) => void |
Returns
() => void. Call it to stop listening.
Types
Types
The types the calls above take and give, with every field. Import any of them in a plugin from @phantomclient/plugin/sdk, or use them as they are in a script.
Membership
What Animal Jam says about the account's membership.
| Field | Type | |
|---|---|---|
userName | string | The account it is about. |
accountType | number | The account type; 2 and above is a member (ACCOUNT_TYPE). |
member | boolean | Whether that makes the account a member, as Utility.isMember decides. |
daysLeft | number | Days left as the server counted them; 0 or -1 when there is nothing to count down. |
endsAt | number | null | When it runs out, from daysLeft at heardAt, to the day; null for a non-member or no end. |
sourceType | string | null | Where it came from (subscriptionSourceType); null when the server sent none. |
heardAt | number | When this was heard or read, in milliseconds since the epoch. |
cause | "client" | "login" | "redeemed" | What said it: the login reply, a membership redeemed in play, or the client's own copy. |
ShownMembership
The membership the game is showing now, as the client holds it.
| Field | Type | |
|---|---|---|
accountType | number | |
member | boolean | |
daysLeft | number |
MembershipLook
A membership show makes the game show.
| Field | Type | |
|---|---|---|
accountType | number | 2 for a member, 3 for a beta member. |
daysLeft | number | The days left shown on the settings screen; -1 shows none. |
ActOptions
How long something that acts may take, and what may end it first.
| Field | Type | |
|---|---|---|
timeoutMs optional | number | undefined | 10 seconds by default. |
signal optional | AbortSignal | undefined |
MembershipUpsell
One of the client's membership adverts, as it went up.
| Field | Type | |
|---|---|---|
page | string | The page of the advert (animals, dens, adventures…); empty for "buy more diamonds". |
reason | string | What the player did to bring it up, as the client names it (equipAccessory, adventure). |
subject | string | null | What they did it to, where the client names one; null otherwise. |
roomName | string | null | The room it was put up for, where the client names one; null otherwise. |