diff --git a/endpoints.go b/endpoints.go index 88663fe8f..421afcbaa 100644 --- a/endpoints.go +++ b/endpoints.go @@ -78,6 +78,7 @@ var ( EndpointUserNotes = func(uID string) string { return EndpointUsers + "@me/notes/" + uID } EndpointGuild = func(gID string) string { return EndpointGuilds + gID } + EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" } EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" } EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" } EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID } diff --git a/restapi.go b/restapi.go index b5e67cb5e..8b5e35733 100644 --- a/restapi.go +++ b/restapi.go @@ -592,6 +592,18 @@ func (s *Session) Guild(guildID string) (st *Guild, err error) { return } +// GuildPreview returns a GuildPreview structure of a specific public Guild. +// guildID : The ID of a Guild +func (s *Session) GuildPreview(guildID string) (st *GuildPreview, err error) { + body, err := s.RequestWithBucketID("GET", EndpointGuildPreview(guildID), nil, EndpointGuildPreview(guildID)) + if err != nil { + return + } + + err = unmarshal(body, &st) + return +} + // GuildCreate creates a new Guild // name : A name for the Guild (2-100 characters) func (s *Session) GuildCreate(name string) (st *Guild, err error) { diff --git a/structs.go b/structs.go index 02ad55193..f8861394b 100644 --- a/structs.go +++ b/structs.go @@ -151,7 +151,7 @@ type Integration struct { SyncedAt Timestamp `json:"synced_at"` } -//ExpireBehavior of Integration +// ExpireBehavior of Integration // https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors type ExpireBehavior int @@ -567,6 +567,40 @@ type Guild struct { Permissions int `json:"permissions"` } +// A GuildPreview holds data related to a specific public Discord Guild, even if the user is not in the guild. +type GuildPreview struct { + // The ID of the guild. + ID string `json:"id"` + + // The name of the guild. (2–100 characters) + Name string `json:"name"` + + // The hash of the guild's icon. Use Session.GuildIcon + // to retrieve the icon itself. + Icon string `json:"icon"` + + // The hash of the guild's splash. + Splash string `json:"splash"` + + // The hash of the guild's discovery splash. + DiscoverySplash string `json:"discovery_splash"` + + // A list of the custom emojis present in the guild. + Emojis []*Emoji `json:"emojis"` + + // The list of enabled guild features + Features []string `json:"features"` + + // Approximate number of members in this guild, returned from the GET /guild/ endpoint when with_counts is true + ApproximateMemberCount int `json:"approximate_member_count"` + + // Approximate number of non-offline members in this guild, returned from the GET /guild/ endpoint when with_counts is true + ApproximatePresenceCount int `json:"approximate_presence_count"` + + // the description for the guild + Description string `json:"description"` +} + // MessageNotifications is the notification level for a guild // https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level type MessageNotifications int