Phantom community
phantom.aj.communityOther players
Phantom's community: who nearby uses Phantom.
Scripts and plugins
A script has all of it, as phantom.aj.community, 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 |
|---|---|---|
hidden() | Everyone this player has hidden, asked of Phantom's server. | game:act |
hide() | Hides someone this player met through Phantom: in the same shared room or real-time channel, or whose shared-room message reached them lately. | game:act |
isAvailable() | Whether this game reaches the community at all: false in a copy of the SDK without it. | game:read |
nearby() | Everybody else in this Animal Jam room running Phantom, and what they show. | game:read |
report() | Reports someone to Phantom's moderators with the latest thing they said in a shared room that reached this player in the last half hour, and a few words of why (up to 200 characters). | game:act |
unhide() | Shows someone hidden again; someone who was not hidden is left as they were. | game:act |
onHidden() | Hears who is hidden change, from this game, another plugin, or another computer on the same account, with everyone hidden now. | game:read |
onNearby() | Hears who else in the room is running Phantom: the whole list again each time somebody walks in or out, changes their perks, or is hidden. | game:read |
Methods
hidden
hidden(options?: ActOptions) => Promise<HiddenPlayer[]>Everyone this player has hidden, asked of Phantom's server. REFUSED when the player is not signed in to Phantom or may not use its community; NOT_READY where there is no community.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<HiddenPlayer[]>
Types
hide
hide(screenName: string, options?: ActOptions) => Promise<HiddenPlayer>Hides someone this player met through Phantom: in the same shared room or real-time channel, or whose shared-room message reached them lately. Resolves once Phantom's server has; throws REFUSED for someone not met, for the player themselves, past 500 hidden, or too often.
Parameters
| Name | Type | |
|---|---|---|
screenName | string | |
options optional | ActOptions |
Returns
Promise<HiddenPlayer>
Types
isAvailable
isAvailable() => booleanWhether this game reaches the community at all: false in a copy of the SDK without it.
Returns
boolean
nearby
nearby() => Promise<NearbyPhantomUser[]>Everybody else in this Animal Jam room running Phantom, and what they show. Empty with presence off in Settings, between rooms, or with nobody else here on Phantom; nobody hidden is ever in it. There is no account and no id in it: a screen name is all.
Returns
Promise<NearbyPhantomUser[]>
Types
report
report(screenName: string, reason?: string, options?: ActOptions) => Promise<void>Reports someone to Phantom's moderators with the latest thing they said in a shared room that reached this player in the last half hour, and a few words of why (up to 200 characters). REFUSED when nothing they said reached the player.
Parameters
| Name | Type | |
|---|---|---|
screenName | string | |
reason optional | string | |
options optional | ActOptions |
Returns
Promise<void>
Types
unhide
unhide(screenName: string, options?: ActOptions) => Promise<void>Shows someone hidden again; someone who was not hidden is left as they were.
Parameters
| Name | Type | |
|---|---|---|
screenName | string | |
options optional | ActOptions |
Returns
Promise<void>
Types
Events
onHidden
onHidden(listener: (hidden: HiddenPlayer[]) => void, options?: { now?: boolean | undefined; }) => () => voidHears who is hidden change, from this game, another plugin, or another computer on the same account, with everyone hidden now. With now, it is told the list as it is first, read after it starts listening so a change in flight is not lost; a first read that fails is logged and the next change is waited for.
Parameters
| Name | Type | |
|---|---|---|
listener | (hidden: HiddenPlayer[]) => void | |
options optional | { now?: boolean | undefined; } |
Returns
() => void. Call it to stop listening.
Types
Example
const stop = phantom.aj.community.onHidden((hidden) => console.log(hidden.length, 'hidden'), {
now: true,
});onNearby
onNearby(listener: (nearby: NearbyPhantomUser[]) => void) => () => voidHears who else in the room is running Phantom: the whole list again each time somebody walks in or out, changes their perks, or is hidden.
Parameters
| Name | Type | |
|---|---|---|
listener | (nearby: NearbyPhantomUser[]) => 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.
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 |
HiddenPlayer
Someone this player hid, by screen name.
| Field | Type | |
|---|---|---|
screenName | string |
NearbyPhantomUser
Somebody else in this Animal Jam room running Phantom, and what they chose to show.
| Field | Type | |
|---|---|---|
screenName | string | Their Animal Jam screen name: how they are matched to the animal in the room. |
perks | PhantomPerks | |
plan | "monthly" | "lifetime" | null | What they pay, only when they switched their plan mark on; null otherwise. |