webhook.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package discordgo
  2. // Webhook stores the data for a webhook.
  3. type Webhook struct {
  4. ID string `json:"id"`
  5. Type WebhookType `json:"type"`
  6. GuildID string `json:"guild_id"`
  7. ChannelID string `json:"channel_id"`
  8. User *User `json:"user"`
  9. Name string `json:"name"`
  10. Avatar string `json:"avatar"`
  11. Token string `json:"token"`
  12. // ApplicationID is the bot/OAuth2 application that created this webhook
  13. ApplicationID string `json:"application_id,omitempty"`
  14. }
  15. // WebhookType is the type of Webhook (see WebhookType* consts) in the Webhook struct
  16. // https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
  17. type WebhookType int
  18. // Valid WebhookType values
  19. const (
  20. WebhookTypeIncoming WebhookType = 1
  21. WebhookTypeChannelFollower WebhookType = 2
  22. )
  23. // WebhookParams is a struct for webhook params, used in the WebhookExecute command.
  24. type WebhookParams struct {
  25. Content string `json:"content,omitempty"`
  26. Username string `json:"username,omitempty"`
  27. AvatarURL string `json:"avatar_url,omitempty"`
  28. TTS bool `json:"tts,omitempty"`
  29. Files []*File `json:"-"`
  30. Components []MessageComponent `json:"components"`
  31. Embeds []*MessageEmbed `json:"embeds,omitempty"`
  32. AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
  33. // NOTE: Works only for followup messages.
  34. Flags uint64 `json:"flags,omitempty"`
  35. }
  36. // WebhookEdit stores data for editing of a webhook message.
  37. type WebhookEdit struct {
  38. Content string `json:"content,omitempty"`
  39. Components []MessageComponent `json:"components"`
  40. Embeds []*MessageEmbed `json:"embeds,omitempty"`
  41. Files []*File `json:"-"`
  42. AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
  43. }