-
Notifications
You must be signed in to change notification settings - Fork 0
/
richpresence.go
59 lines (50 loc) · 1.02 KB
/
richpresence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"time"
"github.com/hugolgst/rich-go/client"
)
type RichPresence struct {
state string
details string
start time.Time
}
func (r *RichPresence) StartRichPresence() error {
err := client.Login("1257854443718836314")
if err != nil {
return err
}
r.state = "Starting..."
r.start = time.Now()
return r.UpdateRichPresence()
}
func (r *RichPresence) StopRichPresence() error {
client.Logout()
return nil
}
func (r *RichPresence) SetRichPresenceState(s string) {
r.state = s
}
func (r *RichPresence) SetRichPresenceDetails(d string) {
r.details = d
}
func (r *RichPresence) UpdateRichPresence() error {
err := client.SetActivity(client.Activity{
State: r.state,
Details: r.details,
Timestamps: &client.Timestamps{
Start: &r.start,
},
LargeImage: "staxie-border",
LargeText: "Open Source 2D/3D sprite stack editor",
Buttons: []*client.Button{
{
Label: "GitHub",
Url: "https://github.com/kettek/staxie",
},
},
})
if err != nil {
return err
}
return nil
}