From ce4bd67f172213764fc7d1ffb6e7774b6bb892ca Mon Sep 17 00:00:00 2001 From: Maximilian von Lindern Date: Tue, 3 Aug 2021 01:14:34 +0200 Subject: [PATCH] discord: Add missing webhook fields (#250) * discord: add missing webhook fields * discord: add missing ,omitempty tags on Webhook * discord: add missing ,omitempty tags on Webhook --- discord/webhook.go | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/discord/webhook.go b/discord/webhook.go index cb61405..0226e93 100644 --- a/discord/webhook.go +++ b/discord/webhook.go @@ -2,17 +2,47 @@ package discord import "time" +// Webhook is used to represent a webhook. +// +// https://discord.com/developers/docs/resources/webhook#webhook-object type Webhook struct { - ID WebhookID `json:"id"` + // ID is the id of the webhook. + ID WebhookID `json:"id"` + // Type is the WebhookType of the webhook. Type WebhookType `json:"type"` - User User `json:"user"` // creator - - GuildID GuildID `json:"guild_id,omitempty"` + // 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. ChannelID ChannelID `json:"channel_id"` + // 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 string `json:"name"` - Avatar Hash `json:"avatar"` - Token string `json:"token"` // incoming webhooks only + // 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"` + + // 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"` } // CreatedAt returns a time object representing when the webhook was created.