From 6d3c73d0179ae6e4c78de291a37d9c7e21401f4f Mon Sep 17 00:00:00 2001 From: Jake Fulmine Date: Fri, 9 Feb 2024 03:21:08 +0100 Subject: [PATCH] fix: properly fall back to regular Url if CleanUrl is not present --- PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs | 2 +- PluralKit.Bot/Commands/Groups.cs | 4 ++-- PluralKit.Bot/Commands/Member.cs | 2 +- PluralKit.Bot/Commands/MemberAvatar.cs | 2 +- PluralKit.Bot/Commands/MemberEdit.cs | 2 +- PluralKit.Bot/Commands/SystemEdit.cs | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs index a42877d0..83bb1028 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextAvatarExt.cs @@ -52,7 +52,7 @@ public static class ContextAvatarExt public struct ParsedImage { public string Url; - public string CleanUrl; + public string? CleanUrl; public AvatarSource Source; public User? SourceUser; } diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index eca6043d..e3f539a2 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -263,7 +263,7 @@ public class Groups await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url); - await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { Icon = img.CleanUrl }); + await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { Icon = img.CleanUrl ?? img.Url }); var msg = img.Source switch { @@ -328,7 +328,7 @@ public class Groups await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url, true); - await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { BannerImage = img.CleanUrl }); + await ctx.Repository.UpdateGroup(target.Id, new GroupPatch { BannerImage = img.CleanUrl ?? img.Url }); var msg = img.Source switch { diff --git a/PluralKit.Bot/Commands/Member.cs b/PluralKit.Bot/Commands/Member.cs index 82d40611..a34087c1 100644 --- a/PluralKit.Bot/Commands/Member.cs +++ b/PluralKit.Bot/Commands/Member.cs @@ -79,7 +79,7 @@ public class Member img.CleanUrl = uriBuilder.Uri.AbsoluteUri; await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url); - await ctx.Repository.UpdateMember(member.Id, new MemberPatch { AvatarUrl = img.CleanUrl }, conn); + await ctx.Repository.UpdateMember(member.Id, new MemberPatch { AvatarUrl = img.CleanUrl ?? img.Url }, conn); dispatchData.Add("avatar_url", img.CleanUrl); } diff --git a/PluralKit.Bot/Commands/MemberAvatar.cs b/PluralKit.Bot/Commands/MemberAvatar.cs index 705d9eae..7986e9d4 100644 --- a/PluralKit.Bot/Commands/MemberAvatar.cs +++ b/PluralKit.Bot/Commands/MemberAvatar.cs @@ -139,7 +139,7 @@ public class MemberAvatar ctx.CheckSystem().CheckOwnMember(target); await AvatarUtils.VerifyAvatarOrThrow(_client, avatarArg.Value.Url); - await UpdateAvatar(location, ctx, target, avatarArg.Value.CleanUrl); + await UpdateAvatar(location, ctx, target, avatarArg.Value.CleanUrl ?? avatarArg.Value.Url); await PrintResponse(location, ctx, target, avatarArg.Value, guildData); } diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index 44b62c6e..b6193249 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -182,7 +182,7 @@ public class MemberEdit { await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url, true); - await ctx.Repository.UpdateMember(target.Id, new MemberPatch { BannerImage = img.CleanUrl }); + await ctx.Repository.UpdateMember(target.Id, new MemberPatch { BannerImage = img.CleanUrl ?? img.Url }); var msg = img.Source switch { diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 2da521b8..b1a73e74 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -475,7 +475,7 @@ public class SystemEdit await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url); - await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { AvatarUrl = img.CleanUrl }); + await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { AvatarUrl = img.CleanUrl ?? img.Url }); var msg = img.Source switch { @@ -543,7 +543,7 @@ public class SystemEdit await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url); - await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { AvatarUrl = img.CleanUrl }); + await ctx.Repository.UpdateSystemGuild(target.Id, ctx.Guild.Id, new SystemGuildPatch { AvatarUrl = img.CleanUrl ?? img.Url }); var msg = img.Source switch { @@ -640,7 +640,7 @@ public class SystemEdit { await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url, true); - await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { BannerImage = img.CleanUrl }); + await ctx.Repository.UpdateSystem(target.Id, new SystemPatch { BannerImage = img.CleanUrl ?? img.Url }); var msg = img.Source switch {