Normalize colors to lowercase hex

This commit is contained in:
Ske 2020-02-25 16:37:52 +01:00
parent e455bd6d12
commit 45c5e5ed42
3 changed files with 3 additions and 3 deletions

View File

@ -77,7 +77,7 @@ namespace PluralKit.API
throw new JsonModelParseError("Member name can not be set to null.");
if (o.ContainsKey("name")) member.Name = o.Value<string>("name").BoundsCheckField(Limits.MaxMemberNameLength, "Member name");
if (o.ContainsKey("color")) member.Color = o.Value<string>("color").NullIfEmpty();
if (o.ContainsKey("color")) member.Color = o.Value<string>("color").NullIfEmpty()?.ToLower();
if (o.ContainsKey("display_name")) member.DisplayName = o.Value<string>("display_name").NullIfEmpty().BoundsCheckField(Limits.MaxMemberNameLength, "Member display name");
if (o.ContainsKey("birthday"))
{

View File

@ -87,7 +87,7 @@ namespace PluralKit.Bot
if (!Regex.IsMatch(color, "^[0-9a-fA-F]{6}$")) throw Errors.InvalidColorError(color);
}
target.Color = color;
target.Color = color?.ToLower();
await _data.SaveMember(target);
await ctx.Reply($"{Emojis.Success} Member color {(color == null ? "cleared" : "changed")}.");

View File

@ -157,7 +157,7 @@ namespace PluralKit.Core
member.Name = dataMember.Name;
if (dataMember.DisplayName != null) member.DisplayName = dataMember.DisplayName;
if (dataMember.Description != null) member.Description = dataMember.Description;
if (dataMember.Color != null) member.Color = dataMember.Color;
if (dataMember.Color != null) member.Color = dataMember.Color.ToLower();
if (dataMember.AvatarUrl != null) member.AvatarUrl = dataMember.AvatarUrl;
if (dataMember.Prefix != null || dataMember.Suffix != null)
{