Hyperfocus

Discord Rich Presence and friends' status for Hyperfocus games

While a game runs, Hyperfocus shows it on the player's Discord profile as a Rich Presence card, and shows it to their Hyperfocus friends as "playing <game>". Your game does not need a Discord library: it sends a few fields to the launcher and the launcher does the rest. This guide covers what the card looks like, what a game may change, and how to do it.

What the card shows

With no input from your game, the card is built from the game's entry in Hyperfocus:

When the launcher is open but no game is running there is no details line, just the Hyperfocus logo and the install button. When the launcher is hidden in the tray the card is cleared. Rich Presence is on by default; players can turn it off in Settings, discord. If Discord is not running, Hyperfocus retries every 30 seconds and nothing ever fails for the game.

What a game can change

Only three things, all through POST /hyperfocus/presence on the game bridge:

FieldEffectLimits
stateThe line under the title on Discord (the details line). Empty goes back to the game's name.up to 128 characters
appIdUse this Discord application for the session, so the card title is that application's name.15 to 22 digits, or empty for the default
statusWhat Hyperfocus friends see next to "playing <game>". Not shown on Discord.up to 128 characters, empty removes it

Everything a game sets lasts until the game closes, or until POST /hyperfocus/presence/reset. The call only works while Hyperfocus has the game running (409 not_running otherwise), unless the developer settings allow it for testing.

curl -X POST http://127.0.0.1:47833/hyperfocus/presence \
  -H "Content-Type: application/json" \
  -d '{"state":"Night 1 - 5 AM"}'

In the Scratch extension:

set Discord status to TEXTuse Discord application ID ID for this sessionreset Discord statusset status for friends to TEXT

Your own Discord application

Discord always puts the application's name in the big title. To make the title your game's name:

  1. Create an application at discord.com/developers named after your game.
  2. Copy its application ID (a long number).
  3. Give the ID to Hyperfocus: for an official game put it in the game's discordAppId setting in the game list (the owner sets it in the official editor, where there is also an optional discordAsset for a Rich Presence asset name). For any other game, send it at runtime with appId or the Scratch block use Discord application ID [ID] for this session.

The community site's editor has no field for a Discord application ID, so community games switch applications from the game itself with appId.

How the member-list line behaves

The short "Playing ..." line in Discord's member list follows this rule, so it never shows a confusing text:

Friends' status in Hyperfocus

Separately from Discord, Hyperfocus tells the player's friends (through Velora) which game they are playing:

curl -X POST http://127.0.0.1:47833/hyperfocus/presence -d '{"status":"In the lobby"}'
curl -X POST http://127.0.0.1:47833/hyperfocus/presence -d '{"status":""}'   # remove it

Testing

Launch the game from Hyperfocus and watch your own Discord profile. To test from the Scratch editor in the browser, turn on Developer Mode in Hyperfocus settings and allow game extension connections with no game open; presence then runs under the game ID you set (or a test ID). The game integration guide explains it.

Questions

Can a game change the whole Discord card?

No. A game can change the line under the title (details), the Discord application used for the session, and the status Hyperfocus friends see. The Hyperfocus badge and the Install HYPERFOCUS button always stay.

Why does the card title say Hyperfocus instead of my game?

The title of a Rich Presence card is the name of the Discord application. Create a Discord application named after your game and use its application ID as discordAppId (official games) or through the presence call or Scratch block (any game).

What if Discord is not running?

Nothing breaks. Hyperfocus retries the connection every 30 seconds and the calls still succeed.

Can players turn it off?

Yes. Rich Presence is a setting in Hyperfocus (Settings, discord) and is on by default.

More Hyperfocus guides