🚀 Use Lanyard API easily in your Go app!

stars license supportServer forks issues

🚀 Go Lanyard

Use Lanyard API easily in your Go app!

📦 Installation

  • Initialize your project (go mod init example.com/example)
  • Add package (go get github.com/barbarbar338/go-lanyard)

🤓 Usage

Using without websocket:

package main

import (
	"fmt"

	"github.com/barbarbar338/go-lanyard"
)

func main() {
	//                              User ID here 👇
	res, err := lanyard.FetchUser("331846231514939392")

	// Handle error
	if err != nil {
		// ...
		panic(err)
	}

	// Handle presence data here
	fmt.Println(res.Data.DiscordStatus)
}

Using with websocket:

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"github.com/barbarbar338/go-lanyard"
)

func main() {
	//                          User ID here 👇
	ws := lanyard.ListenUser("331846231514939392", func(data *lanyard.LanyardData) {
		// Handle presence data here
		fmt.Println(data.DiscordStatus)
	})

	sc := make(chan os.Signal, 1)
	signal.Notify(
		sc,
		syscall.SIGINT,
		syscall.SIGTERM,
		os.Interrupt,
	)
	<-sc

	fmt.Println("Closing client.")

	// Destroy WS before exit
	ws.Destroy()
}

Using websocket for watching multiple users:

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"github.com/barbarbar338/go-lanyard"
)

func main() {
	//                                                     User IDs here 👇
	ws := lanyard.ListenMultipleUsers([]string{"866849747603816468", "331846231514939392"}, func(data *lanyard.LanyardData) {
		fmt.Println(data.DiscordStatus)
	})

	sc := make(chan os.Signal, 1)
	signal.Notify(
		sc,
		syscall.SIGINT,
		syscall.SIGTERM,
		os.Interrupt,
	)
	<-sc

	fmt.Println("Closing client.")

	// Destroy WS before exit
	ws.Destroy()
}

📄 License

Copyright © 2021 Barış DEMİRCİ.

Distributed under the GPL-3.0 License. See LICENSE for more information.

🧦 Contributing

Feel free to use GitHub's features.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Commit your Changes (git commit -m 'my awesome feature my-feature')
  4. Push to the Branch (git push origin feature/my-feature)
  5. Open a Pull Request

🔥 Show your support

Give a ⭐️ if this project helped you!

📞 Contact

Special Thanks

Owner
Barış DEMİRCİ
Back-end developer with over 10 years experience. More interested in TypeScript and Go.
Barış DEMİRCİ
Similar Resources

Use controllers with the Gorilla Mux library

Gorilla Controllers Use controllers with the Gorilla Mux library Why controllers? Gorilla's mux library is a brilliant fully featured mux tool, Gorill

Nov 22, 2022

Easy to use, light enough, good performance Golang library

 Easy to use, light enough, good performance Golang library

指令使用 特性 简单易用、足够轻量,避免过多的外部依赖,最低兼容 Window 7 等老系统 快速上手 安装 $ go get github.com/sohaha/zlsgo HTTP 服务 // main.go

Dec 29, 2022

DO NOT use `named return values` in Go

namedreturn DO NOT use named return values in Go namedreturn finds a named return value, you must remove it.

Dec 17, 2021

To run a .go file use below syntax

To run a .go file use below syntax

Nov 2, 2021

A very simplified Mux focused for ease of use.

hyper-mux A very simplified Mux focused for ease of use. go get github.com/hyperjumptech/hyper-mux How to use the Mux The following is how you going t

Aug 23, 2022

code that I re-use among many Go projects

A bunch of Go packages that I use in multiple projects. An overview of packages: u : utility functions that I use all the time. Very short package nam

Dec 30, 2022

Go 1.18 generics use cases and examples

Go 1.18 generics use cases What are generics? See Type Parameters Proposal. How to run the examples? As of today, gotip is the simplest way to run the

Jan 10, 2022

Use is a go utility library using go1.18 generics

use use is a go utility library using go1.18 generics created by halpdesk 2022-01-22 use/slice Map updates a slice by applying a function to all membe

Jan 22, 2022

Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang)

Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang)

Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang). It has support for Windows too! The API can be used in several ways, pick one that suits you.

Feb 5, 2022
✔️ Get random data for your app from a third-party source.

Random Data Securely produced random data for application testing. FAQ What would i use this data for? You can use this information to test your apps

Jul 5, 2022
Hotswap provides a solution for reloading your go code without restarting your server, interrupting or blocking any ongoing procedure.
Hotswap provides a solution for reloading your go code without restarting your server, interrupting or blocking any ongoing procedure.

Hotswap provides a solution for reloading your go code without restarting your server, interrupting or blocking any ongoing procedure. Hotswap is built upon the plugin mechanism.

Jan 5, 2023
Sample app that prints the compute region it’s running on

This web application prints the Google Cloud datacenter it’s running on with information about where the datacenter is located (city, country and flag). It's used to demonstrate global load balancing capabilities of Google Cloud HTTPS Load Balancer, as it routes the request to the compute region closest to the visitor.

Jan 1, 2023
this is an api that execute your deno code and send you the output

this a simple api that execute your deno code and send you the output, has not limit per request example request: in deno: const rawResponse = await f

Dec 23, 2022
A simple API for computing diffs of your documents over the time built on a scalable technology stack.

Diffme API WIP - this is an API to compute diffs between documents. It serves as a way to easily create audit logs for documents in your system, think

Sep 8, 2021
Helpers for making the use of reflection easier

go-xray This is a Golang library with reflection related functions which I use in my different projects. KeyValue This type is used to construct a key

Oct 24, 2022
Use Golang to implement PHP's common built-in functions.

PHP2Go Use Golang to implement PHP's common built-in functions. About 140+ functions have been implemented. Install go get github.com/syyongx/php2go R

Dec 28, 2022
Robust & Easy to use struct mapper and utility methods for Go

go-model Robust & Easy to use model mapper and utility methods for Go struct. Typical methods increase productivity and make Go development more fun ?

Dec 30, 2022
Go linter to check the struct literal to use field name

Structfield Find struct literals using non-labeled fields. The structfield analysis reports the usage of struct literal using non-labeled fields more

Aug 23, 2021
Infrastructure supporting the use of Go in Microsoft

Microsoft Go Infrastructure This repository contains libraries and utilities that Microsoft uses to: Build Go inside Microsoft infrastructure using up

Dec 15, 2022