|
@@ -182,91 +182,6 @@ func unmarshal(data []byte, v interface{}) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) Login(email, password string) (err error) {
|
|
|
-
|
|
|
- data := struct {
|
|
|
- Email string `json:"email"`
|
|
|
- Password string `json:"password"`
|
|
|
- }{email, password}
|
|
|
-
|
|
|
- response, err := s.RequestWithBucketID("POST", EndpointLogin, data, EndpointLogin)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- temp := struct {
|
|
|
- Token string `json:"token"`
|
|
|
- MFA bool `json:"mfa"`
|
|
|
- }{}
|
|
|
-
|
|
|
- err = unmarshal(response, &temp)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- s.Token = temp.Token
|
|
|
- s.MFA = temp.MFA
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) Register(username string) (token string, err error) {
|
|
|
-
|
|
|
- data := struct {
|
|
|
- Username string `json:"username"`
|
|
|
- }{username}
|
|
|
-
|
|
|
- response, err := s.RequestWithBucketID("POST", EndpointRegister, data, EndpointRegister)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- temp := struct {
|
|
|
- Token string `json:"token"`
|
|
|
- }{}
|
|
|
-
|
|
|
- err = unmarshal(response, &temp)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- token = temp.Token
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) Logout() (err error) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if s.Token == "" {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- data := struct {
|
|
|
- Token string `json:"token"`
|
|
|
- }{s.Token}
|
|
|
-
|
|
|
- _, err = s.RequestWithBucketID("POST", EndpointLogout, data, EndpointLogout)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -307,8 +222,8 @@ func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error) {
|
|
|
+
|
|
|
+func (s *Session) UserUpdate(username, avatar string) (st *User, err error) {
|
|
|
|
|
|
|
|
|
|
|
@@ -316,12 +231,9 @@ func (s *Session) UserUpdate(email, password, username, avatar, newPassword stri
|
|
|
|
|
|
|
|
|
data := struct {
|
|
|
- Email string `json:"email,omitempty"`
|
|
|
- Password string `json:"password,omitempty"`
|
|
|
- Username string `json:"username,omitempty"`
|
|
|
- Avatar string `json:"avatar,omitempty"`
|
|
|
- NewPassword string `json:"new_password,omitempty"`
|
|
|
- }{email, password, username, avatar, newPassword}
|
|
|
+ Username string `json:"username,omitempty"`
|
|
|
+ Avatar string `json:"avatar,omitempty"`
|
|
|
+ }{username, avatar}
|
|
|
|
|
|
body, err := s.RequestWithBucketID("PATCH", EndpointUser("@me"), data, EndpointUsers)
|
|
|
if err != nil {
|
|
@@ -332,39 +244,6 @@ func (s *Session) UserUpdate(email, password, username, avatar, newPassword stri
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func (s *Session) UserSettings() (st *Settings, err error) {
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("GET", EndpointUserSettings("@me"), nil, EndpointUserSettings(""))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) UserUpdateStatus(status Status) (st *Settings, err error) {
|
|
|
- if status == StatusOffline {
|
|
|
- err = ErrStatusOffline
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- data := struct {
|
|
|
- Status Status `json:"status"`
|
|
|
- }{status}
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("PATCH", EndpointUserSettings("@me"), data, EndpointUserSettings(""))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
func (s *Session) UserConnections() (conn []*UserConnection, err error) {
|
|
|
response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"))
|
|
@@ -380,19 +259,6 @@ func (s *Session) UserConnections() (conn []*UserConnection, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) UserChannels() (st []*Channel, err error) {
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("GET", EndpointUserChannels("@me"), nil, EndpointUserChannels(""))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error) {
|
|
@@ -443,20 +309,6 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGui
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) UserGuildSettingsEdit(guildID string, settings *UserGuildSettingsEdit) (st *UserGuildSettings, err error) {
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("PATCH", EndpointUserGuildSettings("@me", guildID), settings, EndpointUserGuildSettings("", guildID))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -1248,15 +1100,6 @@ func (s *Session) GuildIntegrationDelete(guildID, integrationID string) (err err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) GuildIntegrationSync(guildID, integrationID string) (err error) {
|
|
|
-
|
|
|
- _, err = s.RequestWithBucketID("POST", EndpointGuildIntegrationSync(guildID, integrationID), nil, EndpointGuildIntegration(guildID, ""))
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
|
|
@@ -1536,21 +1379,6 @@ func (s *Session) ChannelMessage(channelID, messageID string) (st *Message, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) ChannelMessageAck(channelID, messageID, lastToken string) (st *Ack, err error) {
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("POST", EndpointChannelMessageAck(channelID, messageID), &Ack{Token: lastToken}, EndpointChannelMessageAck(channelID, ""))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -1958,18 +1786,6 @@ func (s *Session) VoiceRegions() (st []*VoiceRegion, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func (s *Session) VoiceICE() (st *VoiceICE, err error) {
|
|
|
-
|
|
|
- body, err := s.RequestWithBucketID("GET", EndpointVoiceIce, nil, EndpointVoiceIce)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &st)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -2348,86 +2164,6 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) UserNoteSet(userID string, message string) (err error) {
|
|
|
- data := struct {
|
|
|
- Note string `json:"note"`
|
|
|
- }{message}
|
|
|
-
|
|
|
- _, err = s.RequestWithBucketID("PUT", EndpointUserNotes(userID), data, EndpointUserNotes(""))
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipsGet() (r []*Relationship, err error) {
|
|
|
- body, err := s.RequestWithBucketID("GET", EndpointRelationships(), nil, EndpointRelationships())
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &r)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) relationshipCreate(userID string, relationshipType int) (err error) {
|
|
|
- data := struct {
|
|
|
- Type int `json:"type"`
|
|
|
- }{relationshipType}
|
|
|
-
|
|
|
- _, err = s.RequestWithBucketID("PUT", EndpointRelationship(userID), data, EndpointRelationships())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipFriendRequestSend(userID string) (err error) {
|
|
|
- err = s.relationshipCreate(userID, 4)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipFriendRequestAccept(userID string) (err error) {
|
|
|
- err = s.relationshipCreate(userID, 1)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipUserBlock(userID string) (err error) {
|
|
|
- err = s.relationshipCreate(userID, 2)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipDelete(userID string) (err error) {
|
|
|
- _, err = s.RequestWithBucketID("DELETE", EndpointRelationship(userID), nil, EndpointRelationships())
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (s *Session) RelationshipsMutualGet(userID string) (mf []*User, err error) {
|
|
|
- body, err := s.RequestWithBucketID("GET", EndpointRelationshipsMutual(userID), nil, EndpointRelationshipsMutual(userID))
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- err = unmarshal(body, &mf)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|