This package provides a super simple interface to send discord messages through webhooks in golang.
go get github.com/godzilla74/discordhook
Below is some example that you can use, and try on example.go right away.
Generate simple message like this.
message := discordhook.Message{
Username: &username,
Content: &message,
}
err := discordhook.SendMessage(url, message)
if err != nil {
log.Fatal(err)
}
Generate some embed message like that. Please note that if you want the field to be inline, pass the Field type to true.
var (
ccy = "BTC"
value = "0.0002"
inline = true
typeName = "type"
valueType = "join"
)
fields := make([]discordhook.Field, 0)
fields = append(fields, discordhook.Field{
Name: &ccy,
Value: &value,
Inline: &inline,
})
fields = append(fields, discordhook.Field{
Name: &typeName,
Value: &valueType,
Inline: &inline,
})
fields = append(fields, discordhook.Field{
Name: &ccy,
Value: &value,
})
embeds := make([]discordhook.Embed, 0)
embeds = append(embeds, discordhook.Embed{
Title: &message,
Description: &description,
Fields: &fields,
})
message := discordhook.Message{
Username: &username,
Content: &message,
Embeds: &embeds,
}
err := discordhook.SendMessage(url, message)
if err != nil {
log.Fatal(err)
}

