webhook

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: ISC Imports: 8 Imported by: 4

Documentation

Overview

Package webhook provides means to interact with webhooks directly and not through the bot API.

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClient = httputil.NewClient()

DefaultHTTPClient is the httputil.Client used in the helper methods.

Functions

func Delete

func Delete(id discord.WebhookID, token string) error

Delete is a shortcut for NewCustomClient(token, id, DefaultHTTPClient).Delete().

func Execute

func Execute(id discord.WebhookID, token string, data api.ExecuteWebhookData) error

Execute is a shortcut for NewCustomClient(token, id, DefaultHTTPClient).Execute(data).

func ExecuteAndWait

func ExecuteAndWait(
	id discord.WebhookID, token string, data api.ExecuteWebhookData) (*discord.Message, error)

ExecuteAndWait is a shortcut for NewCustomClient(token, id, DefaultHTTPClient).ExecuteAndWait(data).

func Get

func Get(id discord.WebhookID, token string) (*discord.Webhook, error)

Get is a shortcut for NewCustomClient(token, id, DefaultHTTPClient).Get().

func Modify

func Modify(
	id discord.WebhookID, token string, data api.ModifyWebhookData) (*discord.Webhook, error)

Modify is a shortcut for NewCustomClient(token, id, DefaultHTTPClient).Modify(data).

Types

type Client

type Client struct {
	// Client is the httputil.Client used to call Discord's API.
	*httputil.Client
	// ID is the id of the webhook.
	ID discord.WebhookID
	// Token is the token of the webhook.
	Token string
}

Client is the client used to interact with a webhook.

func NewClient

func NewClient(id discord.WebhookID, token string) *Client

NewClient creates a new Client using the passed token and id.

func NewCustomClient

func NewCustomClient(id discord.WebhookID, token string, c *httputil.Client) *Client

NewCustomClient creates a new Client creates a new Client using the passed token and id and makes API calls using the passed httputil.Client

func (*Client) Delete

func (c *Client) Delete() error

Delete deletes a webhook permanently.

func (*Client) Execute

func (c *Client) Execute(data api.ExecuteWebhookData) (err error)

Execute sends a message to the webhook, but doesn't wait for the message to get created. This is generally faster, but only applicable if no further interaction is required.

func (*Client) ExecuteAndWait

func (c *Client) ExecuteAndWait(data api.ExecuteWebhookData) (*discord.Message, error)

ExecuteAndWait executes the webhook, and waits for the generated discord.Message to be returned.

func (*Client) Get

func (c *Client) Get() (*discord.Webhook, error)

Get gets the webhook.

func (*Client) Modify

func (c *Client) Modify(data api.ModifyWebhookData) (*discord.Webhook, error)

Modify modifies the webhook.

Jump to

Keyboard shortcuts

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