Explorar o código

Do not allow sending role colors > 0xFFFFFF

Bruce Marriner %!s(int64=8) %!d(string=hai) anos
pai
achega
e2e03c3078
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      restapi.go

+ 5 - 0
restapi.go

@@ -716,6 +716,11 @@ func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
 // perm      : The permissions for the role.
 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 {
 		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