mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 14:57:54 +00:00
feat(apiv2): guild endpoints
This commit is contained in:
parent
eb05cbf76c
commit
f602f22a3d
7 changed files with 242 additions and 33 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue