Discord presence for golang that sucks less.
go get -u github.com/dragsbruh/gopresenceSee hello.go for a proper working example.
client := presence.New()
// Connect to Discord's IPC socket
client.Connect()
// Defer disconnect
defer client.Close()
// Send handshake with ClientID
readyEv, err := client.Login("<CLIENT_ID>")
log.Printf("connected to discord as user %s", readyEv.User.GlobalName)
// Send SET_ACTIVITY request (fire and forget)
client.SetActivity(presence.SetActivityArgs{
PID: os.Getpid(),
Activity: presence.Activity{
Name: "Fonta Drinking Simulator",
Type: presence.ActivityListening,
State: "Leading with the highest score",
Details: "Drinking Fonta",
Buttons: []presence.Button{
{Label: "What is Hearth?", URL: "https://hearth.is-a.dev"},
},
Party: &presence.Party{
ID: uuid.NewString(),
Size: [2]int{3, 4},
},
Assets: &presence.Assets{
LargeImage: "https://files.hearth.is-a.dev/public/avatars/arle.png",
LargeText: "Join Palais Mermonia!",
LargeURL: "https://discord.gg/BK9sBWdWC4",
SmallImage: "https://files.hearth.is-a.dev/public/avatars/iostpa.jpg",
SmallText: "Join is-a.dev!",
SmallURL: "https://discord.gg/DsdeaG3hRV",
},
},
})NOTE: Above example does not handle errors to keep it short
I highly recommend reading the function signatures and source code directly, it's super small.
- See rpc.go for available functions.
- See types.go for available fields.
- See ipc/ipc.go for raw IPC usage.
Currently the library only supports Login and SetActivity methods, so I recommend you use client.GetIPC
to get the underlying IPC socket along with the helpers for advanced usage.
If you think said usage should be a feature in the library, feel free to open an issue or PR.
- Support for Windows
- MacOS and Linux (native + snap)
Under BSD-2-Clause


