https://github.com/etaaa/go-webhooks
An easy to use Golang package to quickly send Discord webhooks
https://github.com/etaaa/go-webhooks
discord discord-webhook go golang webhook webhooks
Last synced: about 1 year ago
JSON representation
An easy to use Golang package to quickly send Discord webhooks
- Host: GitHub
- URL: https://github.com/etaaa/go-webhooks
- Owner: etaaa
- License: mit
- Created: 2021-08-07T22:07:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-12-04T16:28:19.000Z (over 3 years ago)
- Last Synced: 2025-03-13T23:14:58.348Z (over 1 year ago)
- Topics: discord, discord-webhook, go, golang, webhook, webhooks
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-webhooks
An easy to use Golang package to quickly send Discord webhooks (https://discord.com/developers/docs/resources/webhook).
## Usage
Install:
```bash
go get github.com/etaaa/go-webhooks
```
Usage:
```go
package main
import (
"log"
wh "github.com/etaaa/go-webhooks"
)
func main() {
// Create a new webhook object. Most fields are optional
webhook := wh.Webhook{
Content: "This is the webhook's content - up to 2000 characters long.",
Username: "go-webhooks",
AvatarUrl: "https://golang.org/lib/godoc/images/footer-gopher.jpg",
Embeds: []wh.Embed{
{
Title: "Embed Title with URL",
Description: "This is the embed's description",
Url: "https://github.com/etaaa/go-webhooks",
Timestamp: wh.GetTimestamp(), // Returns a new timestamp matching Discords format
Color: wh.GetColor("#00ff00"), // Returns the color in decimal value matching Discords format
Footer: wh.EmbedFooter{
Text: "Sent via github.com/etaaa/go-webhooks",
},
Thumbnail: wh.EmbedThumbnail{
Url: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Go_Logo_Blue.svg/1200px-Go_Logo_Blue.svg.png",
},
Author: wh.EmbedAuthor{
Name: "eta",
Url: "https://github.com/etaaa",
IconUrl: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
},
Fields: []wh.EmbedFields{
{
Name: "Field 1",
Value: "Text here",
},
},
},
},
}
// Send the webhook
if err := wh.SendWebhook("https://discord.com/api/webhooks/.../...", webhook, true); err != nil {
log.Fatal(err)
}
}
```
## Questions
For any questions feel free to add and DM me on Discord (eta#1656).
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)