Skip to content

godzilla74/discordhook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discordhook

This package provides a super simple interface to send discord messages through webhooks in golang.

Installation

go get github.com/godzilla74/discordhook

Example

Below is some example that you can use, and try on example.go right away.

Simple Message

Generate simple message like this.

	message := discordhook.Message{
		Username: &username,
		Content:  &message,
	}

	err := discordhook.SendMessage(url, message)
	if err != nil {
		log.Fatal(err)
	}

image

Message with Embeds

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)
	}

image

About

Discord Webhook

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%