diff --git a/endpoints.go b/endpoints.go index 4b81983..f63240f 100644 --- a/endpoints.go +++ b/endpoints.go @@ -62,6 +62,7 @@ var ( 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 } + EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID } EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" } EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID } EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" } diff --git a/restapi.go b/restapi.go index 9eead00..3704886 100644 --- a/restapi.go +++ b/restapi.go @@ -732,6 +732,28 @@ func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err err return } +// GuildMemberRoleAdd adds the specified role to a given member +// guildID : The ID of a Guild. +// userID : The ID of a User. +// roleID : The ID of a Role to be assigned to the user. +func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID string) (err error) { + + _, err = s.RequestWithBucketID("PUT", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, userID, roleID)) + + return +} + +// GuildMemberRoleRemove removes the specified role to a given member +// guildID : The ID of a Guild. +// userID : The ID of a User. +// roleID : The ID of a Role to be removed from the user. +func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string) (err error) { + + _, err = s.RequestWithBucketID("DELETE", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, userID, roleID)) + + return +} + // GuildChannels returns an array of Channel structures for all channels of a // given guild. // guildID : The ID of a Guild. diff --git a/structs.go b/structs.go index b2d8aad..f2d0a2e 100644 --- a/structs.go +++ b/structs.go @@ -291,6 +291,7 @@ type Game struct { URL string `json:"url"` } +// UnmarshalJSON unmarshals json to Game struct func (g *Game) UnmarshalJSON(bytes []byte) error { temp := &struct { Name string `json:"name"`