discordhooks

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 7 Imported by: 1

README

DiscordHooks (Simple discord webhooks for Go)

Simple package to send embeds to a Discord Webhook with Go

Installation

go get github.com/JuandeJuni/discordhooks

Usage

Send Webhook with a single Embed
//Import the package

import (
    "github.com/JuandeJuni/discordhooks"
)

//Creating the Embed

embed = discordhooks.Embed{
    Title: "Title",
    Description: "Description",
    Color: 0x00ff00,
    Url: "https://google.com",
    Thumbnail: discordhooks.Thumbnail{
        Url: "https://www.trecebits.com/wp-content/uploads/2015/09/google.jpg",
    },
    Fields: []discordhooks.Field{
        discordhooks.Field{
            Name: "Field 1",
            Value: "Value 1",
        },
        discordhooks.Field{
            Name: "Field 2",
            Value: "Value 2",
        },
    },
}

//Sending the webhook

discordhooks.SendEmbed("https://discordapp.com/api/webhooks/your/webhook", embed)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteWebhook added in v0.0.5

func ExecuteWebhook(link string, data []byte) error

func SendEmbed

func SendEmbed(username string, sitelogo string, link string, embeds EmbedS) error

}

func SendEmbeds

func SendEmbeds(link string, embeds []EmbedS) error

Types

type Attachment added in v0.0.4

type Attachment struct {
	ID          string `json:"id"`
	Description string `json:"description"`
	Filename    string `json:"filename"`
}

type AuthorS added in v0.1.2

type AuthorS struct {
	Name string `json:"name"`
}

type EmbedS added in v0.1.2

type EmbedS struct {
	Title       string     `json:"title"`
	Description string     `json:"description"`
	URL         string     `json:"url"`
	Color       int        `json:"color"`
	Fields      []FieldS   `json:"fields"`
	Author      AuthorS    `json:"author"`
	Footer      FooterS    `json:"footer"`
	Timestamp   time.Time  `json:"timestamp"`
	Thumbnail   ThumbnailS `json:"thumbnail"`
}

type FieldS added in v0.1.2

type FieldS struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline,omitempty"`
}

type FooterS added in v0.1.2

type FooterS struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url"`
}

type NewHook added in v0.1.2

type NewHook struct {
	Content     string       `json:"content"`
	Embeds      []EmbedS     `json:"embeds"`
	Username    string       `json:"username"`
	AvatarURL   string       `json:"avatar_url"`
	Attachments []Attachment `json:"attachments"`
}

type ThumbnailS added in v0.1.2

type ThumbnailS struct {
	Url string `json:"url"`
}

Jump to

Keyboard shortcuts

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