2020-01-19 02:27:30 +00:00
|
|
|
package discord
|
|
|
|
|
2021-05-20 22:47:44 +00:00
|
|
|
import "time"
|
|
|
|
|
2021-08-02 23:14:34 +00:00
|
|
|
// Webhook is used to represent a webhook.
|
|
|
|
//
|
|
|
|
// https://discord.com/developers/docs/resources/webhook#webhook-object
|
2020-01-19 02:27:30 +00:00
|
|
|
type Webhook struct {
|
2021-08-02 23:14:34 +00:00
|
|
|
// ID is the id of the webhook.
|
|
|
|
ID WebhookID `json:"id"`
|
|
|
|
// Type is the WebhookType of the webhook.
|
2020-01-19 02:27:30 +00:00
|
|
|
Type WebhookType `json:"type"`
|
2021-08-02 23:14:34 +00:00
|
|
|
// GuildID is the guild id this webhook is for, if any.
|
|
|
|
GuildID GuildID `json:"guild_id,omitempty"`
|
|
|
|
// ChannelID is the channel id this webhook is for, if any.
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID ChannelID `json:"channel_id"`
|
2021-08-02 23:14:34 +00:00
|
|
|
// User is the user this webhook was created by.
|
|
|
|
//
|
|
|
|
// This field is not returned when getting a webhook with its token.
|
|
|
|
User *User `json:"user,omitempty"`
|
|
|
|
|
|
|
|
// Name is the default name of the webhook.
|
|
|
|
Name string `json:"name"`
|
|
|
|
// Avatar is the default user avatar hash of the webhook.
|
|
|
|
Avatar Hash `json:"avatar"`
|
|
|
|
// Token is the secure token of the webhook, returned for incoming
|
|
|
|
// webhooks.
|
|
|
|
Token string `json:"token,omitempty"`
|
|
|
|
|
|
|
|
// ApplicationID is the bot/OAuth2 application that created this webhook.
|
|
|
|
ApplicationID AppID `json:"application_id"`
|
2020-01-19 02:27:30 +00:00
|
|
|
|
2021-08-02 23:14:34 +00:00
|
|
|
// SourceGuild is the guild of the channel that this webhook is following.
|
|
|
|
// It is returned for channel follower webhooks.
|
|
|
|
//
|
|
|
|
// This field will only be filled partially.
|
|
|
|
SourceGuild *Guild `json:"source_guild,omitempty"`
|
|
|
|
// SourceChannel is the channel that this webhook is following. It is
|
|
|
|
// returned for channel follower webhooks.
|
|
|
|
//
|
|
|
|
// This field will only be filled partially.
|
|
|
|
SourceChannel *Channel `json:"source_channel,omitempty"`
|
|
|
|
// URL is the url used for executing the webhook. It is returned by the
|
|
|
|
// webhooks OAuth2 flow.
|
|
|
|
URL URL `json:"url,omitempty"`
|
2020-01-19 02:27:30 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 22:47:44 +00:00
|
|
|
// CreatedAt returns a time object representing when the webhook was created.
|
|
|
|
func (w Webhook) CreatedAt() time.Time {
|
|
|
|
return w.ID.Time()
|
|
|
|
}
|
|
|
|
|
2020-01-19 02:27:30 +00:00
|
|
|
type WebhookType uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ WebhookType = iota
|
|
|
|
IncomingWebhook
|
|
|
|
ChannelFollowerWebhook
|
|
|
|
)
|