feat(apiv2): guild endpoints
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
			
		||||
#nullable enable
 | 
			
		||||
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
 | 
			
		||||
using SqlKata;
 | 
			
		||||
 | 
			
		||||
namespace PluralKit.Core
 | 
			
		||||
@@ -13,5 +15,28 @@ namespace PluralKit.Core
 | 
			
		||||
            .With("display_name", DisplayName)
 | 
			
		||||
            .With("avatar_url", AvatarUrl)
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        public new void AssertIsValid()
 | 
			
		||||
        {
 | 
			
		||||
            if (DisplayName.Value != null)
 | 
			
		||||
                AssertValid(DisplayName.Value, "display_name", Limits.MaxMemberNameLength);
 | 
			
		||||
            if (AvatarUrl.Value != null)
 | 
			
		||||
                AssertValid(AvatarUrl.Value, "avatar_url", Limits.MaxUriLength,
 | 
			
		||||
                    s => MiscUtils.TryMatchUri(s, out var avatarUri));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
        public static MemberGuildPatch FromJson(JObject o)
 | 
			
		||||
        {
 | 
			
		||||
            var patch = new MemberGuildPatch();
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("display_name"))
 | 
			
		||||
                patch.DisplayName = o.Value<string>("display_name").NullIfEmpty();
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("avatar_url"))
 | 
			
		||||
                patch.AvatarUrl = o.Value<string>("avatar_url").NullIfEmpty();
 | 
			
		||||
 | 
			
		||||
            return patch;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
#nullable enable
 | 
			
		||||
 | 
			
		||||
using Newtonsoft.Json.Linq;
 | 
			
		||||
 | 
			
		||||
using SqlKata;
 | 
			
		||||
 | 
			
		||||
namespace PluralKit.Core
 | 
			
		||||
@@ -19,5 +21,33 @@ namespace PluralKit.Core
 | 
			
		||||
            .With("tag", Tag)
 | 
			
		||||
            .With("tag_enabled", TagEnabled)
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        public new void AssertIsValid()
 | 
			
		||||
        {
 | 
			
		||||
            if (Tag.Value != null)
 | 
			
		||||
                AssertValid(Tag.Value, "tag", Limits.MaxSystemTagLength);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#nullable disable
 | 
			
		||||
        public static SystemGuildPatch FromJson(JObject o, MemberId? memberId)
 | 
			
		||||
        {
 | 
			
		||||
            var patch = new SystemGuildPatch();
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("proxying_enabled") && o["proxying_enabled"].Type != JTokenType.Null)
 | 
			
		||||
                patch.ProxyEnabled = o.Value<bool>("proxying_enabled");
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("autoproxy_mode") && o["autoproxy_mode"].ParseAutoproxyMode() is { } autoproxyMode)
 | 
			
		||||
                patch.AutoproxyMode = autoproxyMode;
 | 
			
		||||
 | 
			
		||||
            patch.AutoproxyMember = memberId;
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("tag"))
 | 
			
		||||
                patch.Tag = o.Value<string>("tag").NullIfEmpty();
 | 
			
		||||
 | 
			
		||||
            if (o.ContainsKey("tag_enabled") && o["tag_enabled"].Type != JTokenType.Null)
 | 
			
		||||
                patch.TagEnabled = o.Value<bool>("tag_enabled");
 | 
			
		||||
 | 
			
		||||
            return patch;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user