Add guild preview endpoint (#818)
This commit is contained in:
parent
2021f608f6
commit
4617d8e379
3 changed files with 48 additions and 1 deletions
|
@ -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 }
|
||||
|
|
12
restapi.go
12
restapi.go
|
@ -588,6 +588,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) {
|
||||
|
|
36
structs.go
36
structs.go
|
@ -152,7 +152,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
|
||||
|
||||
|
@ -572,6 +572,40 @@ type Guild struct {
|
|||
Permissions int64 `json:"permissions,string"`
|
||||
}
|
||||
|
||||
// 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/<id> 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/<id> 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
|
||||
|
|
Loading…
Reference in a new issue