Discord Rich Presence from Nexium

statusmith is a tray app for custom Discord Rich Presence, and its nexium/ directory is the same protocol written in Nexium, with no dependency on the app: open the local pipe, handshake, set_activity, clear, close, in about three hundred lines. It is the first package outside this repository, and the shape a package beside an app takes (dir, in packages).

nx add discord_rpc --git https://github.com/Londopy/statusmith --tag sdk-v0.1.0 --dir nexium

A card on your profile#

import discord_rpc

fn main() -> !void {
    var a = discord_rpc.activity()
    a.details = String.from("writing the compiler in itself")
    a.state = String.from("1.3.2")
    a.start_ms = time.now()                                      // an elapsed timer
    var client = try discord_rpc.connect("1234567890123456789")  // your Application ID
    let headline = try client.set_activity(&a)                   // "Playing <headline>"
    println("on your profile: {}", .{headline})
    ...
    try client.clear()
    client.close()                                               // Discord clears the card
}

activity() is a card with nothing on it; the fields are details and state (the two lines), kind (playing, listening, watching, competing), large_image, large_text, small_image, small_text (an Art Assets key or an https:// link), start_ms and end_ms (an elapsed timer or a countdown), and two buttons with a label and a URL. Empty strings and zero timestamps are left out of the request. connect(app_id) opens \\.\pipe\discord-ipc-N and handshakes; set_activity(&a) returns the application's name; the presence stays up while the connection is open.

What to know#