-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathwebhook_client.go
57 lines (48 loc) · 2.94 KB
/
webhook_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package webhook
import (
"context"
"errors"
"github.com/disgoorg/snowflake/v2"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/rest"
)
var ErrInvalidWebhookURL = errors.New("invalid webhook URL")
// Client is a high level interface for interacting with Discord's Webhooks API.
type Client interface {
// ID returns the configured Webhook id
ID() snowflake.ID
// Token returns the configured Webhook token
Token() string
// URL returns the full Webhook URL
URL() string
// Close closes all connections the Webhook Client has open
Close(ctx context.Context)
// Rest returns the underlying rest.Webhooks
Rest() rest.Webhooks
// GetWebhook fetches the current Webhook from discord
GetWebhook(opts ...rest.RequestOpt) (*discord.IncomingWebhook, error)
// UpdateWebhook updates the current Webhook
UpdateWebhook(webhookUpdate discord.WebhookUpdateWithToken, opts ...rest.RequestOpt) (*discord.IncomingWebhook, error)
// DeleteWebhook deletes the current Webhook
DeleteWebhook(opts ...rest.RequestOpt) error
// CreateMessage creates a new Message from the discord.WebhookMessageCreate
CreateMessage(messageCreate discord.WebhookMessageCreate, opts ...rest.RequestOpt) (*discord.Message, error)
// CreateMessageInThread creates a new Message from the discord.WebhookMessageCreate in the provided thread
CreateMessageInThread(messageCreate discord.WebhookMessageCreate, threadID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
// CreateContent creates a new Message from the provided content
CreateContent(content string, opts ...rest.RequestOpt) (*discord.Message, error)
// CreateEmbeds creates a new Message from the provided discord.Embed(s)
CreateEmbeds(embeds []discord.Embed, opts ...rest.RequestOpt) (*discord.Message, error)
// UpdateMessage updates an already sent Webhook Message with the discord.WebhookMessageUpdate
UpdateMessage(messageID snowflake.ID, messageUpdate discord.WebhookMessageUpdate, opts ...rest.RequestOpt) (*discord.Message, error)
// UpdateMessageInThread updates an already sent Webhook Message with the discord.WebhookMessageUpdate in the provided thread
UpdateMessageInThread(messageID snowflake.ID, messageUpdate discord.WebhookMessageUpdate, threadID snowflake.ID, opts ...rest.RequestOpt) (*discord.Message, error)
// UpdateContent updates an already sent Webhook Message with the content
UpdateContent(messageID snowflake.ID, content string, opts ...rest.RequestOpt) (*discord.Message, error)
// UpdateEmbeds updates an already sent Webhook Message with the discord.Embed(s)
UpdateEmbeds(messageID snowflake.ID, embeds []discord.Embed, opts ...rest.RequestOpt) (*discord.Message, error)
// DeleteMessage deletes an already sent Webhook Message
DeleteMessage(messageID snowflake.ID, opts ...rest.RequestOpt) error
// DeleteMessageInThread deletes an already sent Webhook Message in the provided thread
DeleteMessageInThread(messageID snowflake.ID, threadID snowflake.ID, opts ...rest.RequestOpt) error
}