feat: per-server keepproxy toggling (#574)

Merges PluralKit/PluralKit#574
This commit is contained in:
Jake Fulmine 2023-08-10 18:15:25 +12:00 committed by Iris System
parent 8a59ef5f50
commit 22ce250b56
11 changed files with 131 additions and 15 deletions

View file

@ -9,6 +9,7 @@ public class MemberGuildSettings
public ulong Guild { get; }
public string? DisplayName { get; }
public string? AvatarUrl { get; }
public bool? KeepProxy { get; }
}
public static class MemberGuildExt
@ -19,6 +20,7 @@ public static class MemberGuildExt
o.Add("display_name", settings.DisplayName);
o.Add("avatar_url", settings.AvatarUrl);
o.Add("keep_proxy", settings.KeepProxy);
return o;
}

View file

@ -10,10 +10,12 @@ public class MemberGuildPatch: PatchObject
{
public Partial<string?> DisplayName { get; set; }
public Partial<string?> AvatarUrl { get; set; }
public Partial<bool?> KeepProxy { get; set; }
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
.With("display_name", DisplayName)
.With("avatar_url", AvatarUrl)
.With("keep_proxy", KeepProxy)
);
public new void AssertIsValid()
@ -36,6 +38,9 @@ public class MemberGuildPatch: PatchObject
if (o.ContainsKey("avatar_url"))
patch.AvatarUrl = o.Value<string>("avatar_url").NullIfEmpty();
if (o.ContainsKey("keep_proxy"))
patch.KeepProxy = o.Value<bool>("keep_proxy");
return patch;
}
@ -51,6 +56,9 @@ public class MemberGuildPatch: PatchObject
if (AvatarUrl.IsPresent)
o.Add("avatar_url", AvatarUrl.Value);
if (KeepProxy.IsPresent)
o.Add("keep_proxy", KeepProxy.Value);
return o;
}
}