IconURL for GuildPreview and GuildWithCounts (#885)
* Add missing field * Helpers * Renames * Use helper * Add withCounts query option to Guild() * Move IconURL * Add IconURL to GuildPreview * Update comments * Send `[]` rather than `null` on empty activities slice * Add more robust file support for webhooks * Add withCounts query option to Guild() * Update comments * Split guild func * Update structs.go Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com> * Update structs.go Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com> * Revert * Format yaml * Add IconURL to GuildPreview * Revert * Revert space * Update restapi.go Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com> * Remove variadic * Revert yamls * Remove param * Hardcode string Co-authored-by: Carson Hoffman <c@rsonhoffman.com> Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
1292ea9e38
commit
cd724aa48a
2 changed files with 31 additions and 3 deletions
15
restapi.go
15
restapi.go
|
@ -472,6 +472,19 @@ func (s *Session) Guild(guildID string) (st *Guild, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// GuildWithCounts returns a Guild structure of a specific Guild with approximate member and presence counts.
|
||||
// guildID : The ID of a Guild
|
||||
func (s *Session) GuildWithCounts(guildID string) (st *Guild, err error) {
|
||||
|
||||
body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID)+"?with_counts=true", nil, EndpointGuild(guildID))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = unmarshal(body, &st)
|
||||
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) {
|
||||
|
@ -515,7 +528,7 @@ func (s *Session) GuildEdit(guildID string, g GuildParams) (st *Guild, err error
|
|||
}
|
||||
}
|
||||
|
||||
//Bounds checking for regions
|
||||
// Bounds checking for regions
|
||||
if g.Region != "" {
|
||||
isValid := false
|
||||
regions, _ := s.VoiceRegions()
|
||||
|
|
19
structs.go
19
structs.go
|
@ -757,16 +757,31 @@ type GuildPreview struct {
|
|||
// The list of enabled guild features
|
||||
Features []string `json:"features"`
|
||||
|
||||
// Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
|
||||
// Approximate number of members in this guild
|
||||
// NOTE: this field is only filled when using GuildWithCounts
|
||||
ApproximateMemberCount int `json:"approximate_member_count"`
|
||||
|
||||
// Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
|
||||
// Approximate number of non-offline members in this guild
|
||||
// NOTE: this field is only filled when using GuildWithCounts
|
||||
ApproximatePresenceCount int `json:"approximate_presence_count"`
|
||||
|
||||
// the description for the guild
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// IconURL returns a URL to the guild's icon.
|
||||
func (g *GuildPreview) IconURL() string {
|
||||
if g.Icon == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if strings.HasPrefix(g.Icon, "a_") {
|
||||
return EndpointGuildIconAnimated(g.ID, g.Icon)
|
||||
}
|
||||
|
||||
return EndpointGuildIcon(g.ID, g.Icon)
|
||||
}
|
||||
|
||||
// GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data.
|
||||
// https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event
|
||||
type GuildScheduledEvent struct {
|
||||
|
|
Loading…
Reference in a new issue