CEEJAYDocs

ceejay.members

Read a member, and link their account in your game or on another platform to their Discord ID.

Every function takes the same last argument, options: signal, timeoutMs and maxRetries, for that one call. A write also takes idempotencyKey there. Every function can also raise the errors any request can raise, such as a bad key or the rate limit. Both are on Errors and retries.

ceejay.members.get

Gets one member: their profile, XP and level, currency and linked accounts, in one call.

GET /v1/members/{discordId} · requires members:read · API reference: Get a member

Retried by the SDK: Yes. It is a read

Takes

Prop

Type

Returns the member, typed as Schemas['Member'].

Prop

Type

Each linked account also carries playerId and playerName under their legacy names, platformUserId and platformUsername. They contain the same values and are still returned.

proof indicates how far a game's playerId can be trusted. It is 'verified' when the player was proven (by the game, or by your own server linking it), 'basic' when the member connected through Connect with a player ID the game only stated, and null for an account that is not a connection to a game. Anyone with the public key a game ships with can claim any ID, so do not grant a member rewards for a 'basic' connection.

Errors

StatuscodeWhen
404member_not_foundCEEJAY has no profile for this member on your server. Discord is not queried

An ID that is not a string of 17 to 20 digits never leaves your server: the SDK throws a TypeError before it sends anything.

Example

ceejay.members.get
import { CeejayError } from '@communitystudios/ceejay'

try {
  const member = await ceejay.members.get('409876543210987654')
  console.log(member.displayName, member.xp, member.level)
  for (const account of member.connections) {
    console.log(account.platform, account.playerId, account.playerName)
  }
} catch (error) {
  if (error instanceof CeejayError && error.code === 'member_not_found') {
    console.log('CEEJAY has not seen this member yet')
  } else {
    throw error
  }
}

Links a member's account in your game, or on another platform such as Twitch, Steam or Roblox, to their Discord ID. Activity on your platform can then be tied to the community member.

POST /v1/members/link · requires members:link · API reference: Link an account

Retried by the SDK: Only with idempotencyKey. Retrying it yourself is safe too: linking the same platform for the same member again updates the link

Takes one object, then options.

Prop

Type

Options

Prop

Type

The API also accepts playerId and playerName under their legacy names, platformUserId and platformUsername, from code that calls it without the SDK. The SDK sends the names in the table.

The member must be in your server. An ID CEEJAY has no profile for is looked up in Discord first. A member who has only just joined can take up to 15 seconds to be found: after a member_not_found for such a member, wait 15 seconds before you retry.

Returns the link, typed as Schemas['LinkedAccount'].

Prop

Type

The response also carries the link under legacy names, which are still returned: id (the same as connectionId, as a number), server_id, user_id (the same as discordId), platform_user_id, platform_username, is_active and connected_at.

Errors

StatuscodeWhen
400unknown_platformThe platform is not one CEEJAY knows, and not one of your community's
400bad_requestA field is missing, too long or contains a character that is not allowed
404member_not_foundThe ID is not a member of your server
404not_availableThis instance has no account linking yet
409linked_by_sign_inThe member linked this platform themselves, by signing in, and you sent a different account. Capitals and spaces at the ends do not make an account different. This stops applying when the member disconnects the account. A link you then make is a new one, also for the same account: it does not bring the member's sign-in back
409player_already_linkedAnother member of your server has already linked that account
503discord_unavailableCEEJAY has no profile for this ID and could not query Discord about it. Retry shortly

A platform that is a game. On an instance that offers Connect, a game that is set up for your community is a platform too: pass its slug as platform. The link is then a game connection at the verified level, because your server vouches for it, and the member is shown no page for it. To let the member confirm the link themselves, use the functions on Connect. For a game, the call can also fail with:

StatuscodeWhen
400bad_player_idplayerId is not one a game can use: 1 to 128 letters, digits and . _ : @ | + = -, starting with a letter or a digit
403community_not_activeThe community removed CEEJAY
403game_not_allowedThe key is limited to other games
403audience_not_allowedThe game is directed at children
404game_not_foundThe game was removed
409game_pausedThe game is paused
403under_ageThe member's connection to this game ended because the player is under age. Only the member connecting again through Connect clears it
409member_disconnectedThe member ended their connection to this game themselves, so only they can connect it again
409player_blockedThe community blocked this player

A connection the member made themselves through Connect is protected like a sign-in: a call that names another playerId is rejected with linked_by_sign_in.

Nothing is changed when a link is rejected. Errors about an idempotency key are described on Errors and retries.

Example

ceejay.members.link
import { CeejayError } from '@communitystudios/ceejay'

try {
  const link = await ceejay.members.link(
    {
      discordId: '409876543210987654',
      platform: 'steam',
      playerId: '76561198012345678',
      playerName: 'nova',
    },
    { idempotencyKey: 'link-steam-76561198012345678' },
  )
  console.log(link.platform, link.playerId, link.connectedAt)
} catch (error) {
  if (error instanceof CeejayError && error.code === 'player_already_linked') {
    console.log('That Steam account belongs to another member')
  } else {
    throw error
  }
}

On this page

Community StudiosPrivacyTerms