Presence API

Use the Nowly Presence API to update Discord Rich Presence from a website integration.

Creating a Presence

Presence is a global injected by the Nowly runtime — you don't need to import it.

Every presence starts with a Presence instance:

const presence = new Presence()

UpdateData Event

Use UpdateData to refresh activity:

presence.on("UpdateData", async () => {
  await presence.setActivity({
    details: "Watching a video",
  })
})

setActivity

setActivity sends the current Discord activity. Common fields include:

FieldTypeDescriptionDefault
detailsstringPrimary activity line shown in Discord.-
statestringSecondary activity line shown below details.-
startTimestampnumberUnix timestamp for elapsed activity progress.-
endTimestampnumberUnix timestamp for remaining activity progress.-
largeImageKeystringMain image asset key, usually Assets.Logo or Assets.Thumbnail (globals provided by the runtime).-
largeImageTextstringTooltip for the large image.-
smallImageKeystringOptional small image asset key.-
smallImageTextstringTooltip for the small image.-
typenumberDiscord activity type from PresenceType.-
buttonsarrayOptional Discord activity buttons.-

clearActivity

Call clearActivity when the user is no longer doing anything worth showing:

presence.clearActivity()

PresenceType

PresenceType is a named export from @nowly/sdk:

import { PresenceType } from "@nowly/sdk"

It maps to Discord activity types: Playing, Streaming, Listening, Watching, and Competing.

Logging

Use presence.info and presence.error for debug messages during development.