From c8b796b2232d34d32e72e5812f372497412bb6ce Mon Sep 17 00:00:00 2001 From: jonas747 Date: Sat, 30 Apr 2016 23:43:05 +0200 Subject: [PATCH 1/2] Add GuildMemberNickname --- restapi.go | 13 +++++++++++++ restapi_test.go | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/restapi.go b/restapi.go index 60d10a2..adc3100 100644 --- a/restapi.go +++ b/restapi.go @@ -665,6 +665,19 @@ func (s *Session) GuildMemberMove(guildID, userID, channelID string) (err error) return } +// GuildMemberNickname updates the nickname of a guild member +// guildID : The ID of a guild +// userID : The ID of a user +func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err error) { + + data := struct { + Nick string `json:"nick"` + }{nickname} + + _, err = s.Request("PATCH", GUILD_MEMBER(guildID, userID), data) + return +} + // GuildChannels returns an array of Channel structures for all channels of a // given guild. // guildID : The ID of a Guild. diff --git a/restapi_test.go b/restapi_test.go index e72a108..c23fb22 100644 --- a/restapi_test.go +++ b/restapi_test.go @@ -186,6 +186,22 @@ func TestGuildRoles(t *testing.T) { } +func TestGuildMemberNickname(t *testing.T) { + + if envGuild == "" { + t.Skip("Skipping, DG_GUILD not set.") + } + + if dg == nil { + t.Skip("Skipping, dg not set.") + } + + err := dg.GuildMemberNickname(envGuild, "@me/nick", "testnickname") + if err != nil { + t.Errorf("GuildNickname returned error: %+v", err) + } +} + // TestChannelMessageSend2 tests the ChannelMessageSend() function. This should not return an error. func TestChannelMessageSend2(t *testing.T) { From 0b313b016febb09ba9a3818e48dc0c37fc089aca Mon Sep 17 00:00:00 2001 From: jonas747 Date: Sat, 30 Apr 2016 23:43:52 +0200 Subject: [PATCH 2/2] Add nick field to guild member struct --- structs.go | 1 + 1 file changed, 1 insertion(+) diff --git a/structs.go b/structs.go index dd7a1fc..d87b191 100644 --- a/structs.go +++ b/structs.go @@ -250,6 +250,7 @@ type Game struct { type Member struct { GuildID string `json:"guild_id"` JoinedAt string `json:"joined_at"` + Nick string `json:"nick"` Deaf bool `json:"deaf"` Mute bool `json:"mute"` User *User `json:"user"`