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:
| Field | Type | Description | Default |
|---|---|---|---|
details | string | Primary activity line shown in Discord. | - |
state | string | Secondary activity line shown below details. | - |
startTimestamp | number | Unix timestamp for elapsed activity progress. | - |
endTimestamp | number | Unix timestamp for remaining activity progress. | - |
largeImageKey | string | Main image asset key, usually Assets.Logo or Assets.Thumbnail (globals provided by the runtime). | - |
largeImageText | string | Tooltip for the large image. | - |
smallImageKey | string | Optional small image asset key. | - |
smallImageText | string | Tooltip for the small image. | - |
type | number | Discord activity type from PresenceType. | - |
buttons | array | Optional 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.