From a6e3be7a36cf0736135b120705ed62f8e2a4ce36 Mon Sep 17 00:00:00 2001 From: Rivalo Date: Thu, 7 Jan 2016 19:00:35 +0100 Subject: [PATCH 1/3] Added register function --- restapi.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/restapi.go b/restapi.go index 2ec276d..31e4ef0 100644 --- a/restapi.go +++ b/restapi.go @@ -119,6 +119,27 @@ func (s *Session) Login(email string, password string) (token string, err error) return } +// Register sends a Register request to Discord, and returns the authentication token +// Note that this account is temporary and should be verified for future use. +// Another option is to save the authentication token external, but this isn't recommended. +func (s *Session) Register(username string) (token string, err error) { + + data := struct { + Username string `json:"username"` + }{username} + + response, err := s.Request("POST", REGISTER, data) + + var temp map[string]interface{} + err = json.Unmarshal(response, &temp) + if err != nil { + return + } + + token = temp["token"].(string) + return +} + // Logout sends a logout request to Discord. // This does not seem to actually invalidate the token. So you can still // make API calls even after a Logout. So, it seems almost pointless to From 7179f550b48b6f7c9de4fe87a0a0020c9bda8d36 Mon Sep 17 00:00:00 2001 From: Rivalo Date: Thu, 7 Jan 2016 19:44:50 +0100 Subject: [PATCH 2/3] Added UserVerify function --- restapi.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/restapi.go b/restapi.go index 31e4ef0..0d64d1c 100644 --- a/restapi.go +++ b/restapi.go @@ -242,6 +242,21 @@ func (s *Session) UserGuilds(userID string) (st []Guild, err error) { return } +// UserVerify updates account information to make vertification possible. +// Account still needs to be activated using the send email +func (s *Session) UserVerify(username, email, password string) (st User, err error) { + + data := struct { + Username string `json:"username"` + Email string `json:"email"` + Password string `json:"password"` + }{username, email, password} + + body, err := s.Request("PATCH", USER("@me"), data) + err = json.Unmarshal(body, &st) + return +} + // ------------------------------------------------------------------------------------------------ // Functions specific to Discord Guilds // ------------------------------------------------------------------------------------------------ From 46a8f39f38e932438db7d775ec542a975d98bb79 Mon Sep 17 00:00:00 2001 From: Rivalo Date: Fri, 8 Jan 2016 02:01:06 +0100 Subject: [PATCH 3/3] Revert "Added UserVerify function" This reverts commit 7179f550b48b6f7c9de4fe87a0a0020c9bda8d36. --- restapi.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/restapi.go b/restapi.go index 0d64d1c..31e4ef0 100644 --- a/restapi.go +++ b/restapi.go @@ -242,21 +242,6 @@ func (s *Session) UserGuilds(userID string) (st []Guild, err error) { return } -// UserVerify updates account information to make vertification possible. -// Account still needs to be activated using the send email -func (s *Session) UserVerify(username, email, password string) (st User, err error) { - - data := struct { - Username string `json:"username"` - Email string `json:"email"` - Password string `json:"password"` - }{username, email, password} - - body, err := s.Request("PATCH", USER("@me"), data) - err = json.Unmarshal(body, &st) - return -} - // ------------------------------------------------------------------------------------------------ // Functions specific to Discord Guilds // ------------------------------------------------------------------------------------------------