Browse Source

Merge pull request #114 from iopred/guilds

Partial support new GuildMember endpoints.
Bruce 9 years ago
parent
commit
f801d95c14
2 changed files with 28 additions and 0 deletions
  1. 1 0
      endpoints.go
  2. 27 0
      restapi.go

+ 1 - 0
endpoints.go

@@ -58,6 +58,7 @@ var (
 	GUILD              = func(gID string) string { return GUILDS + gID }
 	GUILD_INIVTES      = func(gID string) string { return GUILDS + gID + "/invites" }
 	GUILD_CHANNELS     = func(gID string) string { return GUILDS + gID + "/channels" }
+	GUILD_MEMBERS      = func(gID string) string { return GUILDS + gID + "/members" }
 	GUILD_MEMBER       = func(gID, uID string) string { return GUILDS + gID + "/members/" + uID }
 	GUILD_BANS         = func(gID string) string { return GUILDS + gID + "/bans" }
 	GUILD_BAN          = func(gID, uID string) string { return GUILDS + gID + "/bans/" + uID }

+ 27 - 0
restapi.go

@@ -451,6 +451,33 @@ func (s *Session) GuildBanDelete(guildID, userID string) (err error) {
 	return
 }
 
+// GuildMembers returns a list of members for a guild.
+// guildID   : The ID of a Guild.
+func (s *Session) GuildMembers(guildID string) (st []*Member, err error) {
+
+	body, err := s.Request("GET", GUILD_MEMBERS(guildID), nil)
+	if err != nil {
+		return
+	}
+
+	err = unmarshal(body, &st)
+	return
+}
+
+// GuildMember returns a members of a guild.
+// guildID   : The ID of a Guild.
+// userID    : The ID of a User
+func (s *Session) GuildMember(guildID, userID string) (st *Member, err error) {
+
+	body, err := s.Request("GET", GUILD_MEMBER(guildID, userID), nil)
+	if err != nil {
+		return
+	}
+
+	err = unmarshal(body, &st)
+	return
+}
+
 // GuildMemberDelete removes the given user from the given guild.
 // guildID   : The ID of a Guild.
 // userID    : The ID of a User