Had a bad response type, did not affect usage with arRPC, however did not work with proper Discord RPC. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
package rpcfetch
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Activity struct {
|
|
// State is the user's current party status, or text used for a custom status
|
|
State string `json:"state,omitempty"`
|
|
// Details is what the player is currently doing
|
|
Details string `json:"details,omitempty"`
|
|
// Timestamps are Unix timestamps for start and/or end of the game
|
|
Timestamps *ActivityTimestamps `json:"timestamps,omitempty"`
|
|
// Assets are images for the presence and their hover texts
|
|
Assets *ActivityAssets `json:"assets,omitempty"`
|
|
// Party is information for the current party of the player
|
|
Party *ActivityParty `json:"party,omitempty"`
|
|
// Secrets for Rich Presence joining and spectating
|
|
Secrets *ActivitySecrets `json:"secrets,omitempty"`
|
|
// Instance is whether or not the activity is an instanced game session
|
|
Instance bool `json:"instance,omitempty"`
|
|
}
|
|
|
|
type ActivityTimestamps struct {
|
|
// Start is the Unix time (in milliseconds) of when the activity started
|
|
Start *int64 `json:"start,omitempty"`
|
|
// End is the Unix time (in milliseconds) of when the activity ends
|
|
End *int64 `json:"end,omitempty"`
|
|
}
|
|
|
|
type ActivityAssets struct {
|
|
// LargeImage is the large image asset
|
|
LargeImage string `json:"large_image,omitempty"`
|
|
// LargeText is the text displayed when hovering over the large image of the activity
|
|
LargeText string `json:"large_text,omitempty"`
|
|
// SmallImage is the small image asset
|
|
SmallImage string `json:"small_image,omitempty"`
|
|
// SmallText is the text displayed when hovering over the small image of the activity
|
|
SmallText string `json:"small_text,omitempty"`
|
|
}
|
|
|
|
type ActivityParty struct {
|
|
// ID of the party
|
|
ID string `json:"id,omitempty"`
|
|
// Size is used to show the party's current and maximum size
|
|
Size *[2]int `json:"size,omitempty"`
|
|
}
|
|
|
|
type ActivitySecrets struct {
|
|
// Join is the secret for joining a party
|
|
Join string `json:"join,omitempty"`
|
|
// Spectate is the secret for spectating a game
|
|
Spectate string `json:"spectate,omitempty"`
|
|
// Match is the secret for a specific instanced match
|
|
Match string `json:"match,omitempty"`
|
|
}
|
|
|
|
type activityArgs struct {
|
|
PID int `json:"pid"`
|
|
Activity *Activity `json:"activity"`
|
|
}
|
|
|
|
func (d *Client) SetActivity(act *Activity) (string, error) {
|
|
if err := d.activate(); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
nonce := uuid.New().String()
|
|
|
|
_, _, err := validateRaw[Response[any]](Heartbeat, "", "SET_ACTIVITY", nonce)(
|
|
d, Heartbeat, Command[activityArgs]{
|
|
Arguments: activityArgs{
|
|
PID: os.Getpid(),
|
|
Activity: act,
|
|
},
|
|
payload: payload{
|
|
Command: "SET_ACTIVITY",
|
|
Nonce: nonce,
|
|
},
|
|
})
|
|
return nonce, err
|
|
}
|