From b0188cd71e32cc9b3345253936c7eaf23cabcc69 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Wed, 27 Jan 2016 01:37:43 -0800 Subject: [PATCH] Support GuildMemberEdit api. --- restapi.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/restapi.go b/restapi.go index e41a0fc..358fc04 100644 --- a/restapi.go +++ b/restapi.go @@ -435,6 +435,27 @@ func (s *Session) GuildMemberDelete(guildID, userID string) (err error) { return } +// GuildMemberEdit edits the roles of a member. +// guildID : The ID of a Guild. +// userID : The ID of a User. +// roles : A list of roles to set on the member. +func (s *Session) GuildMemberEdit(guildID, userID string, roles []*Role) (err error) { + data := struct { + Roles []string `json:"roles"` + }{[]string{}} + + for _, r := range roles { + data.Roles = append(data.Roles, r.ID) + } + + _, err = s.Request("PATCH", GUILD_MEMBER(guildID, userID), data) + if err != nil { + return + } + + return +} + // GuildChannels returns an array of Channel structures for all channels of a // given guild. // guildID : The ID of a Guild.