discord

package
v0.0.0-...-bb60f61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package discord provide types for interacting with discord webhooks.

Index

Constants

View Source
const (
	ColourRed   = 0x992D22
	ColourGreen = 0x2ECC71
	ColourGrey  = 0x95A5A6
)

Constants for colours.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string `json:"message"`
}

The APIError type represents an error returned from the discord API.

func (APIError) Error

func (err APIError) Error() string

type AlertDispatcher

type AlertDispatcher struct {
	// contains filtered or unexported fields
}

The AlertDispatcher type is used to convert alert manager alerts into discord webhooks.

func NewAlertDispatcher

func NewAlertDispatcher(webhookURL string) *AlertDispatcher

NewAlertDispatcher returns a new AlertDispatcher that will convert alert manager webhooks into discord webhooks and send them to the given URL.

func (*AlertDispatcher) Dispatch

func (a *AlertDispatcher) Dispatch(ctx context.Context, webhook alertmanager.Webhook) error

Dispatch an alert manager webhook to a discord webhook.

type Embed

type Embed struct {
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Colour      int       `json:"color"`
	Fields      []Field   `json:"fields"`
	URL         string    `json:"url"`
	Timestamp   time.Time `json:"timestamp"`
}

The Embed type represents embeddable data in a discord message.

type Field

type Field struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

The Field type represents a single field in a discord message.

type Webhook

type Webhook struct {
	Content string  `json:"content"`
	Embeds  []Embed `json:"embeds"`
}

The Webhook type describes the payload of a discord webhook.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL