|
@@ -218,10 +218,9 @@ func (s *Session) User(userID string) (st *User, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
|
|
|
-
|
|
|
u, err := s.User(userID)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -322,6 +321,11 @@ func (s *Session) UserGuilds() (st []*Guild, err error) {
|
|
|
|
|
|
|
|
|
func (s *Session) Guild(guildID string) (st *Guild, err error) {
|
|
|
+
|
|
|
+ st, err = s.State.Guild(guildID)
|
|
|
+ if err == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
body, err := s.Request("GET", GUILD(guildID), nil)
|
|
|
if err != nil {
|
|
@@ -499,6 +503,7 @@ func (s *Session) GuildInviteCreate(guildID string, i *Invite) (st *Invite, err
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
func (s *Session) GuildRoles(guildID string) (st []*Role, err error) {
|
|
|
|
|
|
body, err := s.Request("GET", GUILD_ROLES(guildID), nil)
|
|
@@ -511,7 +516,8 @@ func (s *Session) GuildRoles(guildID string) (st []*Role, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
|
|
|
|
|
|
body, err := s.Request("POST", GUILD_ROLES(guildID), nil)
|
|
@@ -525,6 +531,12 @@ func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
func (s *Session) GuildRoleEdit(guildID, roleID, name string, color int, hoist bool, perm int) (st *Role, err error) {
|
|
|
|
|
|
data := struct {
|
|
@@ -545,7 +557,9 @@ func (s *Session) GuildRoleEdit(guildID, roleID, name string, color int, hoist b
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (s *Session) GuildRoleReorder(guildID string, roles []Role) (st []*Role, err error) {
|
|
|
+
|
|
|
+
|
|
|
+func (s *Session) GuildRoleReorder(guildID string, roles []*Role) (st []*Role, err error) {
|
|
|
|
|
|
body, err := s.Request("PATCH", GUILD_ROLES(guildID), roles)
|
|
|
if err != nil {
|
|
@@ -558,6 +572,8 @@ func (s *Session) GuildRoleReorder(guildID string, roles []Role) (st []*Role, er
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
func (s *Session) GuildRoleDelete(guildID, roleID string) (err error) {
|
|
|
|
|
|
_, err = s.Request("DELETE", GUILD_ROLE(guildID, roleID), nil)
|
|
@@ -565,6 +581,50 @@ func (s *Session) GuildRoleDelete(guildID, roleID string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
|
|
|
+ g, err := s.Guild(guildID)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.Icon == "" {
|
|
|
+ err = errors.New("Guild does not have an icon set.")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ body, err := s.Request("GET", GUILD_ICON(guildID, g.Icon), nil)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ img, _, err = image.Decode(bytes.NewReader(body))
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (s *Session) GuildSplash(guildID string) (img image.Image, err error) {
|
|
|
+ g, err := s.Guild(guildID)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if g.Splash == "" {
|
|
|
+ err = errors.New("Guild does not have a splash set.")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ body, err := s.Request("GET", GUILD_SPLASH(guildID, g.Splash), nil)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ img, _, err = image.Decode(bytes.NewReader(body))
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|