Merge branch 'develop' of https://github.com/bwmarrin/Discordgo into develop
This commit is contained in:
commit
6de9b19ac8
2 changed files with 62 additions and 41 deletions
34
message.go
34
message.go
|
@ -30,11 +30,41 @@ type Message struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// An Attachment stores data for message attachments.
|
// An Attachment stores data for message attachments.
|
||||||
type Attachment struct { //TODO figure this out
|
type Attachment struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
ProxyURL string `json:"proxy_url"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
Size int `json:"size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// An Embed stores data for message embeds.
|
// An Embed stores data for message embeds.
|
||||||
type Embed struct { // TODO figure this out
|
type Embed struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Thumbnail *struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
ProxyURL string `json:"proxy_url"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
} `json:"thumbnail"`
|
||||||
|
Provider *struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"provider"`
|
||||||
|
Author *struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"author"`
|
||||||
|
Video *struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Width int `json:"width"`
|
||||||
|
Height int `json:"height"`
|
||||||
|
} `json:"video"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentWithMentionsReplaced will replace all @<id> mentions with the
|
// ContentWithMentionsReplaced will replace all @<id> mentions with the
|
||||||
|
|
69
restapi.go
69
restapi.go
|
@ -189,28 +189,6 @@ func (s *Session) User(userID string) (st *User, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserUpdate updates a users settings.
|
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
|
||||||
func (s *Session) UserUpdate(userID, email, password, username, avatar, newPassword string) (st *User, err error) {
|
|
||||||
|
|
||||||
// NOTE: Avatar must be either the hash/id of existing Avatar or
|
|
||||||
// data:image/png;base64,BASE64_STRING_OF_NEW_AVATAR_PNG
|
|
||||||
// to set a new avatar.
|
|
||||||
// If left blank, avatar will be set to null/blank
|
|
||||||
|
|
||||||
data := struct {
|
|
||||||
Email string `json:"email"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Avatar string `json:"avatar,omitempty"`
|
|
||||||
NewPassword string `json:"new_password,omitempty"`
|
|
||||||
}{email, password, username, avatar, newPassword}
|
|
||||||
|
|
||||||
body, err := s.Request("PATCH", USER(userID), data)
|
|
||||||
err = json.Unmarshal(body, &st)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserAvatar returns an image.Image of a users Avatar
|
// UserAvatar returns an image.Image of a users Avatar
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
// userID : A user ID or "@me" which is a shortcut of current user ID
|
||||||
func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
|
func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
|
||||||
|
@ -227,49 +205,62 @@ func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserUpdate updates a users settings.
|
||||||
|
func (s *Session) UserUpdate(email, password, username, avatar, newPassword string) (st *User, err error) {
|
||||||
|
|
||||||
|
// NOTE: Avatar must be either the hash/id of existing Avatar or
|
||||||
|
// data:image/png;base64,BASE64_STRING_OF_NEW_AVATAR_PNG
|
||||||
|
// to set a new avatar.
|
||||||
|
// If left blank, avatar will be set to null/blank
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Email string `json:"email"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Avatar string `json:"avatar,omitempty"`
|
||||||
|
NewPassword string `json:"new_password,omitempty"`
|
||||||
|
}{email, password, username, avatar, newPassword}
|
||||||
|
|
||||||
|
body, err := s.Request("PATCH", USER("@me"), data)
|
||||||
|
err = json.Unmarshal(body, &st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// UserSettings returns the settings for a given user
|
// UserSettings returns the settings for a given user
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
|
||||||
// This seems to only return a result for "@me"
|
|
||||||
func (s *Session) UserSettings(userID string) (st *Settings, err error) {
|
func (s *Session) UserSettings(userID string) (st *Settings, err error) {
|
||||||
|
|
||||||
body, err := s.Request("GET", USER_SETTINGS(userID), nil)
|
body, err := s.Request("GET", USER_SETTINGS("@me"), nil)
|
||||||
err = json.Unmarshal(body, &st)
|
err = json.Unmarshal(body, &st)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserChannels returns an array of Channel structures for all private
|
// UserChannels returns an array of Channel structures for all private
|
||||||
// channels for a user
|
// channels.
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
func (s *Session) UserChannels() (st []*Channel, err error) {
|
||||||
func (s *Session) UserChannels(userID string) (st []*Channel, err error) {
|
|
||||||
|
|
||||||
body, err := s.Request("GET", USER_CHANNELS(userID), nil)
|
body, err := s.Request("GET", USER_CHANNELS("@me"), nil)
|
||||||
err = json.Unmarshal(body, &st)
|
err = json.Unmarshal(body, &st)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserChannelCreate creates a new User (Private) Channel with another User
|
// UserChannelCreate creates a new User (Private) Channel with another User
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
|
||||||
// recipientID : A user ID for the user to which this channel is opened with.
|
// recipientID : A user ID for the user to which this channel is opened with.
|
||||||
func (s *Session) UserChannelCreate(userID, recipientID string) (st *Channel, err error) {
|
func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error) {
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
RecipientID string `json:"recipient_id"`
|
RecipientID string `json:"recipient_id"`
|
||||||
}{recipientID}
|
}{recipientID}
|
||||||
|
|
||||||
body, err := s.Request(
|
body, err := s.Request("POST", USER_CHANNELS("@me"), data)
|
||||||
"POST",
|
|
||||||
USER_CHANNELS(userID),
|
|
||||||
data)
|
|
||||||
|
|
||||||
err = json.Unmarshal(body, &st)
|
err = json.Unmarshal(body, &st)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserGuilds returns an array of Guild structures for all guilds for a given user
|
// UserGuilds returns an array of Guild structures for all guilds.
|
||||||
// userID : A user ID or "@me" which is a shortcut of current user ID
|
func (s *Session) UserGuilds() (st []*Guild, err error) {
|
||||||
func (s *Session) UserGuilds(userID string) (st []*Guild, err error) {
|
|
||||||
|
|
||||||
body, err := s.Request("GET", USER_GUILDS(userID), nil)
|
body, err := s.Request("GET", USER_GUILDS("@me"), nil)
|
||||||
err = json.Unmarshal(body, &st)
|
err = json.Unmarshal(body, &st)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue