Do not allow sending role colors > 0xFFFFFF

This commit is contained in:
Bruce Marriner 2016-04-25 15:19:23 -05:00
parent 0d1f5f55fb
commit e2e03c3078

View file

@ -716,6 +716,11 @@ func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
// perm : The permissions for the role. // perm : The permissions for the role.
func (s *Session) GuildRoleEdit(guildID, roleID, name string, color int, hoist bool, perm int) (st *Role, err error) { func (s *Session) GuildRoleEdit(guildID, roleID, name string, color int, hoist bool, perm int) (st *Role, err error) {
// Prevent sending a color int that is too big.
if color > 0xFFFFFF {
err = fmt.Errorf("color value cannot be larger than 0xFFFFFF")
}
data := struct { data := struct {
Name string `json:"name"` // The color the role should have (as a decimal, not hex) Name string `json:"name"` // The color the role should have (as a decimal, not hex)
Color int `json:"color"` // Whether to display the role's users separately Color int `json:"color"` // Whether to display the role's users separately