An open API service indexing awesome lists of open source software.

https://github.com/codemicro/pkwebhooktranslator

Golang library to translate PluralKit webhook dispatch events to Discord message embeds
https://github.com/codemicro/pkwebhooktranslator

Last synced: about 2 hours ago
JSON representation

Golang library to translate PluralKit webhook dispatch events to Discord message embeds

Awesome Lists containing this project

README

          

# pkWebhookTranslator

*Golang library to translate [PluralKit](https://www.pluralkit.me) webhook dispatch events to Discord message embeds*

---

## Installation

```
go get github.com/codemicro/pkWebhookTranslator/whTranslate
```

## Usage

```go
translator := whtranslate.NewTranslator()
dgSession, _ := discordgo.New()

// receive dispatch event from PluralKit, unmarshal into a *whtranslate.DispatchEvent and validate `signing_token`

discordEmbed, err := translator.Translate(dispatchEvent)
if err != nil {
// ...
}

_, err := dgSession.WebhookExecute(whID, whToken, true, &discordgo.WebhookParams{Embeds: []*discordgo.MessageEmbed{discordEmbed}})
if err != nil {
// ...
}
```

See [main.go](examples/main.go) for an example webhook server implementation.

## License

`pkWebhookTranslate` is distributed under the MIT license. See [LICENSE](LICENSE) for more details.