dishook

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 6 Imported by: 0

README

Dishook

A discord webhook package helper. Please read the reference

Usage

Donwload the package

go get github.com/xpartacvs/go-dishook@v1.2.0

Package in action:

package main

import "github.com/xpartacvs/go-dishook"

func main() {
    webhookUrl := "https://domain.tld/your/discord/webhook/url"

    payload := dishook.Payload{
        Username:  "Dishook",
        AvatarUrl: "https://pbs.twimg.com/profile_images/554798224154701824/mWd3laxO_400x400.png",
        Content:   "Greeting! This message was sent using github.com/xpartacvs/go-dishook",
    }

    _, _ = dishook.Send(webhookUrl, payload)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Post added in v1.3.0

func Post(url string, payload Payload) (reso *http.Response, err error)

func Send

func Send(url string, payload Payload) ([]byte, error)

Types

type Author

type Author struct {
	Name string `json:"name"`
	Image
	Icon
}

type Color added in v1.3.1

type Color uint
const (
	ColorTrace Color = 3092790
	ColorDebug Color = 10170623
	ColorInfo  Color = 3581519
	ColorWarn  Color = 14327864
	ColorError Color = 13631488
	ColorPanic Color = 13631488
	ColorFatal Color = 13631488
)

type Embed

type Embed struct {
	Author      Author  `json:"author,omitempty"`
	Title       string  `json:"title,omitempty"`
	Url         Url     `json:"url,omitempty"`
	Description string  `json:"description,omitempty"`
	Color       Color   `json:"color,omitempty"`
	Fields      []Field `json:"fields,omitempty"`
	Thumbnail   Image   `json:"thumbnail,omitempty"`
	Image       Image   `json:"image,omitempty"`
	Footer      Footer  `json:"footer,omitempty"`
}

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline,omitempty"`
}
type Footer struct {
	Text string `json:"text"`
	Icon
}

type Icon

type Icon struct {
	IconUrl Url `json:"icon_url,omitempty"`
}

type Image

type Image struct {
	ImageUrl Url `json:"url,omitempty"`
}

type Payload

type Payload struct {
	Username  string  `json:"username,omitempty"`
	AvatarUrl Url     `json:"avatar_url,omitempty"`
	Content   string  `json:"content"`
	Tts       bool    `json:"tts,omitempty"`
	Embeds    []Embed `json:"embeds,omitempty"`
}

type Url

type Url string

func (Url) MarshalJSON

func (u Url) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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