Browse Source

Merge pull request #110 from iopred/guildleave

Support new guild leave API.
Bruce 9 years ago
parent
commit
0dea8696c0
2 changed files with 10 additions and 1 deletions
  1. 1 0
      endpoints.go
  2. 9 1
      restapi.go

+ 1 - 0
endpoints.go

@@ -50,6 +50,7 @@ var (
 	USER_AVATAR      = func(uID, aID string) string { return USERS + uID + "/avatars/" + aID + ".jpg" }
 	USER_SETTINGS    = func(uID string) string { return USERS + uID + "/settings" }
 	USER_GUILDS      = func(uID string) string { return USERS + uID + "/guilds" }
+	USER_GUILD       = func(uID, gID string) string { return USERS + uID + "/guilds/" + gID }
 	USER_CHANNELS    = func(uID string) string { return USERS + uID + "/channels" }
 	USER_DEVICES     = func(uID string) string { return USERS + uID + "/devices" }
 	USER_CONNECTIONS = func(uID string) string { return USERS + uID + "/connections" }

+ 9 - 1
restapi.go

@@ -390,7 +390,7 @@ func (s *Session) GuildEdit(guildID, name string) (st *Guild, err error) {
 	return
 }
 
-// GuildDelete deletes or leaves a Guild.
+// GuildDelete deletes a Guild.
 // guildID   : The ID of a Guild
 func (s *Session) GuildDelete(guildID string) (st *Guild, err error) {
 
@@ -403,6 +403,14 @@ func (s *Session) GuildDelete(guildID string) (st *Guild, err error) {
 	return
 }
 
+// GuildLeave leaves a Guild.
+// guildID   : The ID of a Guild
+func (s *Session) GuildLeave(guildID string) (err error) {
+
+	_, err = s.Request("DELETE", USER_GUILD("@me", guildID), nil)
+	return
+}
+
 // GuildBans returns an array of User structures for all bans of a
 // given guild.
 // guildID   : The ID of a Guild.