Skip to content

PresenceData Interface

The PresenceData interface defines the structure of the data that is sent to Discord to display in the user's status. It allows you to customize what information is shown in the Discord Activity.

Structure

The PresenceData interface is a union of two interfaces:

  • MediaPresenceData: For activities related to media (watching or listening)
  • NonMediaPresenceData: For other types of activities

Both extend the BasePresenceData interface, which contains the common properties.

Properties

Common Properties (BasePresenceData)

PropertyTypeDescription
namestringName to show in activity (e.g., "YouTube")
typeActivityTypeType of activity (Playing, Listening, Watching, Competing)
stateDisplayTypeStatusDisplayTypeControls which field is displayed in the user's status text in the member list
detailsstring | Node | nullTop row of the status
detailsUrlstring | nullURL that is linked when clicking on the details text
statestring | Node | nullBottom row of the status
stateUrlstring | nullURL that is linked when clicking on the state text
startTimestampnumber | Date | nullTimestamp for the start of the activity (shows time as "elapsed")
endTimestampnumber | Date | nullTimestamp until the end of the activity (shows time as "remaining")
largeImageKeystring | Blob | HTMLImageElement | nullLarge profile artwork. Preferably a direct URL to an image (e.g., https://example.com/logo.png)
largeImageUrlstring | nullURL that is opened when clicking on the large image
smallImageKeystring | Blob | HTMLImageElement | nullSmall profile artwork. Preferably a direct URL to an image (e.g., https://example.com/icon.png)
smallImageUrlstring | nullURL that is opened when clicking on the small image
smallImageTextstring | Node | nullTooltip for the smallImageKey
buttons[ButtonData, ButtonData?]Array of buttons (max 2)

Media-Specific Properties (MediaPresenceData)

PropertyTypeDescription
typeActivityType.Listening | ActivityType.WatchingMust be either Listening or Watching
largeImageTextstring | Node | nullTooltip for the largeImageKey

Non-Media Properties (NonMediaPresenceData)

PropertyTypeDescription
typeExclude<ActivityType, ActivityType.Listening | ActivityType.Watching>Cannot be Listening or Watching
largeImageTextneverNot allowed for non-media activities

ButtonData Interface

The ButtonData interface defines the structure of buttons that can be added to the presence.

PropertyTypeDescription
labelstring | Node | nullText for the button
urlstring | HTMLAnchorElement | nullURL of button link

ActivityType Enum

The ActivityType enum defines the types of activities that can be displayed.

ValueDescriptionExample
PlayingShows as "Playing [name]""Playing Minecraft"
ListeningShows as "Listening to [name]""Listening to Spotify"
WatchingShows as "Watching [name]""Watching YouTube"
CompetingShows as "Competing in [name]""Competing in a tournament"

StatusDisplayType Enum

The StatusDisplayType enum controls which field is displayed in the user's status text in the member list.

ValueDescriptionExample
NameDisplay the activity name"Playing [name]"
StateDisplay the state field"Listening to [state]"
DetailsDisplay the details field"Watching [details]"

Examples

Basic Presence

typescript
const presenceData: PresenceData = {
  details: 'Browsing the homepage',
  state: 'Reading articles',
  largeImageKey: ActivityAssets.Logo,
  startTimestamp: browsingTimestamp
}

Media Presence (Watching)

typescript
const presenceData: PresenceData = {
  type: ActivityType.Watching,
  details: 'Watching a video',
  state: 'Video Title',
  largeImageKey: ActivityAssets.Logo,
  largeImageText: 'Website Name',
};

[presenceData.startTimestamp, presenceData.endTimestamp] = getTimestampsFromMedia(document.querySelector('video'))

Special Season and Episode Formatting

When using ActivityType.Watching, Discord provides special formatting for TV shows with seasons and episodes. If you set the largeImageText property to follow the pattern "word digit, digit", Discord will automatically display a special season and episode indicator in "S1E2" format.

For example:

typescript
// This will display a special season and episode indicator in Discord
presenceData.type = ActivityType.Watching
presenceData.largeImageText = 'Season 2, Episode 5'

The important part is the pattern: any word, followed by a space, followed by a digit, followed by a comma and space, followed by another digit. While you can use "Season 2, Episode 5" as shown above, the actual word doesn't matter - Discord automatically detects this pattern and converts it to "S2E5" format in the display.

This special formatting only works when the activity type is set to ActivityType.Watching.

Here's how it looks in Discord:

Season and Episode Indicator in Discord

Note: This image shows how Discord displays the special season and episode indicator (S1E2) when using the correct formatting pattern.

Presence with Buttons

typescript
const presenceData: PresenceData = {
  details: 'Reading an article',
  state: 'Article Title',
  largeImageKey: ActivityAssets.Logo,
  buttons: [
    {
      label: 'Read Article',
      url: 'https://example.com/article'
    },
    {
      label: 'Visit Website',
      url: 'https://example.com'
    }
  ]
}

Notes

  • The details and state fields have a maximum length of 128 characters.
  • Button labels have a maximum length of 32 characters.
  • Button URLs must be valid HTTPS URLs.
  • You can have a maximum of 2 buttons.
  • The startTimestamp and endTimestamp can be provided as either a Unix timestamp in milliseconds or a Date object.
  • If both startTimestamp and endTimestamp are provided, only the endTimestamp will be used to show "remaining" time.

Released under the MPL-2.0 License.