webhook.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }
  34. // WebhookEdit stores data for editing of a webhook message.
  35. type WebhookEdit struct {
  36. Content string `json:"content,omitempty"`
  37. Components []MessageComponent `json:"components"`
  38. Embeds []*MessageEmbed `json:"embeds,omitempty"`
  39. Files []*File `json:"-"`
  40. AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
  41. }