From 45c5e5ed422119f77be5bb2f19ef11eb89f5641d Mon Sep 17 00:00:00 2001 From: Ske Date: Tue, 25 Feb 2020 16:37:52 +0100 Subject: [PATCH] Normalize colors to lowercase hex --- PluralKit.API/Utils/JsonModelExt.cs | 2 +- PluralKit.Bot/Commands/MemberEdit.cs | 2 +- PluralKit.Core/Services/DataFileService.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PluralKit.API/Utils/JsonModelExt.cs b/PluralKit.API/Utils/JsonModelExt.cs index d2cc3673..d6d6ddf9 100644 --- a/PluralKit.API/Utils/JsonModelExt.cs +++ b/PluralKit.API/Utils/JsonModelExt.cs @@ -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("name").BoundsCheckField(Limits.MaxMemberNameLength, "Member name"); - if (o.ContainsKey("color")) member.Color = o.Value("color").NullIfEmpty(); + if (o.ContainsKey("color")) member.Color = o.Value("color").NullIfEmpty()?.ToLower(); if (o.ContainsKey("display_name")) member.DisplayName = o.Value("display_name").NullIfEmpty().BoundsCheckField(Limits.MaxMemberNameLength, "Member display name"); if (o.ContainsKey("birthday")) { diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index 100465c2..b6243c42 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -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")}."); diff --git a/PluralKit.Core/Services/DataFileService.cs b/PluralKit.Core/Services/DataFileService.cs index 3a0f6c50..f6a984c0 100644 --- a/PluralKit.Core/Services/DataFileService.cs +++ b/PluralKit.Core/Services/DataFileService.cs @@ -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) {