webgook

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 8 Imported by: 0

README

webgook

A simple discord go library to send webhooks.

Example

package main

import "github.com/MoltenCoreDev/webgook"

func main() {
	wh := Webhook{
		Url:      "https://discord.com/api/webhooks/id/token", // You can copy this from the channel settings, where you create the webhook
		Username: "Use discohook today!",
		Content:  "Now with attachment support!",
		Files:    []string{"input.gif"},
	}
	wh.Send()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Webhook

type Webhook struct {
	// You can get this from the channel integration setting menu.
	Url      string `json:"-"`
	Content  string `json:"content,omitempty"`
	ThreadId string `json:"-"`
	// Changes the shown username of webhook's message.
	Username string `json:"username,omitempty"`
	// Changes the shown avatar of webhook's message.
	AvatarURL     string   `json:"avatar_url,omitempty"`
	Tts           bool     `json:"tts,omitempty"`
	Files         []string `json:"-"` // Paths to files to upload
	AllowEveryone bool     `json:"-"`
	// THIS FIELD IS GOING TO GET OVERWRITTEN cry about it lmao
	AllowedMentions map[string][]string `json:"allowed_mentions,omitempty"`
}

A webhook is a struct that contains the information needed to execute a webhook.

func (*Webhook) Send

func (w *Webhook) Send() error

Send() will execute the webhook, effectively sending a message to the channel it was created in.

Jump to

Keyboard shortcuts

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