github.com/meowstercatel/discordgo@v0.0.0-20250615204139-29b43d676735/webhook.go (about)

     1  package discordgo
     2  
     3  // Webhook stores the data for a webhook.
     4  type Webhook struct {
     5  	ID        string      `json:"id"`
     6  	Type      WebhookType `json:"type"`
     7  	GuildID   string      `json:"guild_id"`
     8  	ChannelID string      `json:"channel_id"`
     9  	User      *User       `json:"user"`
    10  	Name      string      `json:"name"`
    11  	Avatar    string      `json:"avatar"`
    12  	Token     string      `json:"token"`
    13  
    14  	// ApplicationID is the bot/OAuth2 application that created this webhook
    15  	ApplicationID string `json:"application_id,omitempty"`
    16  }
    17  
    18  // WebhookType is the type of Webhook (see WebhookType* consts) in the Webhook struct
    19  // https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
    20  type WebhookType int
    21  
    22  // Valid WebhookType values
    23  const (
    24  	WebhookTypeIncoming        WebhookType = 1
    25  	WebhookTypeChannelFollower WebhookType = 2
    26  )
    27  
    28  // WebhookParams is a struct for webhook params, used in the WebhookExecute command.
    29  type WebhookParams struct {
    30  	Content         string                  `json:"content,omitempty"`
    31  	Username        string                  `json:"username,omitempty"`
    32  	AvatarURL       string                  `json:"avatar_url,omitempty"`
    33  	TTS             bool                    `json:"tts,omitempty"`
    34  	Files           []*File                 `json:"-"`
    35  	Components      []MessageComponent      `json:"components"`
    36  	Embeds          []*MessageEmbed         `json:"embeds,omitempty"`
    37  	Attachments     []*MessageAttachment    `json:"attachments,omitempty"`
    38  	AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
    39  	// Only MessageFlagsSuppressEmbeds and MessageFlagsEphemeral can be set.
    40  	// MessageFlagsEphemeral can only be set when using Followup Message Create endpoint.
    41  	Flags MessageFlags `json:"flags,omitempty"`
    42  	// Name of the thread to create.
    43  	// NOTE: can only be set if the webhook channel is a forum.
    44  	ThreadName string `json:"thread_name,omitempty"`
    45  }
    46  
    47  // WebhookEdit stores data for editing of a webhook message.
    48  type WebhookEdit struct {
    49  	Content         *string                 `json:"content,omitempty"`
    50  	Components      *[]MessageComponent     `json:"components,omitempty"`
    51  	Embeds          *[]*MessageEmbed        `json:"embeds,omitempty"`
    52  	Files           []*File                 `json:"-"`
    53  	Attachments     *[]*MessageAttachment   `json:"attachments,omitempty"`
    54  	AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
    55  }