Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gopresence

Discord presence for golang that sucks less.

example listening example playing example competing

Quick Start

go get -u github.com/dragsbruh/gopresence

Example

See 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

Reference

I highly recommend reading the function signatures and source code directly, it's super small.

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.

TO-DO

  • Support for Windows
  • MacOS and Linux (native + snap)

License

Under BSD-2-Clause

About

discord presence for golang that doesnt suck

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages