From a165a42046f68f98f6f4a01236a84d8a1fee1d66 Mon Sep 17 00:00:00 2001 From: spiral Date: Mon, 13 Sep 2021 01:22:40 -0400 Subject: [PATCH] fix MatchRaw commands *again* --- PluralKit.Bot/Commands/Groups.cs | 36 +++++++------- PluralKit.Bot/Commands/MemberEdit.cs | 72 ++++++++++++++-------------- PluralKit.Bot/Commands/SystemEdit.cs | 50 +++++++++---------- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/PluralKit.Bot/Commands/Groups.cs b/PluralKit.Bot/Commands/Groups.cs index 9e327dbe..4639c766 100644 --- a/PluralKit.Bot/Commands/Groups.cs +++ b/PluralKit.Bot/Commands/Groups.cs @@ -103,7 +103,15 @@ namespace PluralKit.Bot // No perms check, display name isn't covered by member privacy - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (target.DisplayName == null) + await ctx.Reply(noDisplayNameSetMessage); + else + await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + if (!ctx.HasNext()) { if (target.DisplayName == null) await ctx.Reply(noDisplayNameSetMessage); @@ -122,14 +130,6 @@ namespace PluralKit.Bot } return; } - if (ctx.MatchRaw()) - { - if (target.DisplayName == null) - await ctx.Reply(noDisplayNameSetMessage); - else - await ctx.Reply($"```\n{target.DisplayName}\n```"); - return; - } ctx.CheckOwnGroup(target); @@ -160,7 +160,15 @@ namespace PluralKit.Bot if (ctx.System?.Id == target.System) noDescriptionSetMessage += $" To set one, type `pk;group {target.Reference()} description `."; - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (target.Description == null) + await ctx.Reply(noDescriptionSetMessage); + else + await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + if (!ctx.HasNext()) { if (target.Description == null) await ctx.Reply(noDescriptionSetMessage); @@ -173,14 +181,6 @@ namespace PluralKit.Bot .Build()); return; } - if (ctx.MatchRaw()) - { - if (target.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{target.Description}\n```"); - return; - } ctx.CheckOwnGroup(target); diff --git a/PluralKit.Bot/Commands/MemberEdit.cs b/PluralKit.Bot/Commands/MemberEdit.cs index 219dc4f0..5c90423c 100644 --- a/PluralKit.Bot/Commands/MemberEdit.cs +++ b/PluralKit.Bot/Commands/MemberEdit.cs @@ -67,7 +67,15 @@ namespace PluralKit.Bot if (!target.DescriptionPrivacy.CanAccess(ctx.LookupContextFor(target.System))) throw Errors.LookupNotAllowed; - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (target.Description == null) + await ctx.Reply(noDescriptionSetMessage); + else + await ctx.Reply($"```\n{target.Description}\n```"); + return; + } + if (!ctx.HasNext()) { if (target.Description == null) await ctx.Reply(noDescriptionSetMessage); @@ -80,14 +88,6 @@ namespace PluralKit.Bot .Build()); return; } - else if (ctx.MatchRaw()) - { - if (target.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{target.Description}\n```"); - return; - } ctx.CheckOwnMember(target); @@ -119,7 +119,15 @@ namespace PluralKit.Bot if (!target.PronounPrivacy.CanAccess(ctx.LookupContextFor(target.System))) throw Errors.LookupNotAllowed; - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (target.Pronouns == null) + await ctx.Reply(noPronounsSetMessage); + else + await ctx.Reply($"```\n{target.Pronouns}\n```"); + return; + } + if (!ctx.HasNext()) { if (target.Pronouns == null) await ctx.Reply(noPronounsSetMessage); @@ -128,14 +136,6 @@ namespace PluralKit.Bot + (ctx.System?.Id == target.System ? $" To clear them, type `pk;member {target.Reference()} pronouns -clear`." : "")); return; } - else if (ctx.MatchRaw()) - { - if (target.Pronouns == null) - await ctx.Reply(noPronounsSetMessage); - else - await ctx.Reply($"```\n{target.Pronouns}\n```"); - return; - } ctx.CheckOwnMember(target); @@ -355,7 +355,15 @@ namespace PluralKit.Bot // No perms check, display name isn't covered by member privacy - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (target.DisplayName == null) + await ctx.Reply(noDisplayNameSetMessage); + else + await ctx.Reply($"```\n{target.DisplayName}\n```"); + return; + } + if (!ctx.HasNext()) { var eb = await CreateMemberNameInfoEmbed(ctx, target); if (ctx.System?.Id == target.System) @@ -365,14 +373,6 @@ namespace PluralKit.Bot await ctx.Reply(embed: eb.Build()); return; } - else if (ctx.MatchRaw()) - { - if (target.DisplayName == null) - await ctx.Reply(noDisplayNameSetMessage); - else - await ctx.Reply($"```\n{target.DisplayName}\n```"); - return; - } ctx.CheckOwnMember(target); @@ -404,15 +404,7 @@ namespace PluralKit.Bot // No perms check, display name isn't covered by member privacy - if (!ctx.HasNext(false)) - { - var eb = await CreateMemberNameInfoEmbed(ctx, target); - if (ctx.System?.Id == target.System) - eb.Description($"To change server name, type `pk;member {target.Reference()} servername `.\nTo clear it, type `pk;member {target.Reference()} servername -clear`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`."); - await ctx.Reply(embed: eb.Build()); - return; - } - else if (ctx.MatchRaw()) + if (ctx.MatchRaw()) { MemberGuildSettings memberGuildConfig = await _db.Execute(c => _repo.GetMemberGuild(c, ctx.Guild.Id, target.Id)); @@ -422,6 +414,14 @@ namespace PluralKit.Bot await ctx.Reply($"```\n{memberGuildConfig.DisplayName}\n```"); return; } + if (!ctx.HasNext()) + { + var eb = await CreateMemberNameInfoEmbed(ctx, target); + if (ctx.System?.Id == target.System) + eb.Description($"To change server name, type `pk;member {target.Reference()} servername `.\nTo clear it, type `pk;member {target.Reference()} servername -clear`.\nTo print the raw server name, type `pk;member {target.Reference()} servername -raw`."); + await ctx.Reply(embed: eb.Build()); + return; + } ctx.CheckOwnMember(target); diff --git a/PluralKit.Bot/Commands/SystemEdit.cs b/PluralKit.Bot/Commands/SystemEdit.cs index 566abef9..fda4e6d9 100644 --- a/PluralKit.Bot/Commands/SystemEdit.cs +++ b/PluralKit.Bot/Commands/SystemEdit.cs @@ -33,14 +33,6 @@ namespace PluralKit.Bot ctx.CheckSystem(); - if (!ctx.HasNext(false)) - { - if (ctx.System.Name != null) - await ctx.Reply($"Your system's name is currently **{ctx.System.Name}**. Type `pk;system name -clear` to clear it."); - else - await ctx.Reply(noNameSetMessage); - return; - } if (ctx.MatchRaw()) { if (ctx.System.Name != null) @@ -49,6 +41,14 @@ namespace PluralKit.Bot await ctx.Reply(noNameSetMessage); return; } + if (!ctx.HasNext()) + { + if (ctx.System.Name != null) + await ctx.Reply($"Your system's name is currently **{ctx.System.Name}**. Type `pk;system name -clear` to clear it."); + else + await ctx.Reply(noNameSetMessage); + return; + } if (await ctx.MatchClear("your system's name")) { @@ -77,7 +77,15 @@ namespace PluralKit.Bot ctx.CheckSystem(); - if (!ctx.HasNext(false)) + if (ctx.MatchRaw()) + { + if (ctx.System.Description == null) + await ctx.Reply(noDescriptionSetMessage); + else + await ctx.Reply($"```\n{ctx.System.Description}\n```"); + return; + } + if (!ctx.HasNext()) { if (ctx.System.Description == null) await ctx.Reply(noDescriptionSetMessage); @@ -89,14 +97,6 @@ namespace PluralKit.Bot .Build()); return; } - if (ctx.MatchRaw()) - { - if (ctx.System.Description == null) - await ctx.Reply(noDescriptionSetMessage); - else - await ctx.Reply($"```\n{ctx.System.Description}\n```"); - return; - } if (await ctx.MatchClear("your system's description")) { @@ -167,14 +167,6 @@ namespace PluralKit.Bot ctx.CheckSystem(); - if (!ctx.HasNext(skipFlags: false)) - { - if (ctx.System.Tag == null) - await ctx.Reply(noTagSetMessage); - else - await ctx.Reply($"Your current system tag is {ctx.System.Tag.AsCode()}. To change it, type `pk;s tag `. To clear it, type `pk;s tag -clear`."); - return; - } if (ctx.MatchRaw()) { if (ctx.System.Tag == null) @@ -183,6 +175,14 @@ namespace PluralKit.Bot await ctx.Reply($"```\n{ctx.System.Tag}\n```"); return; } + if (!ctx.HasNext()) + { + if (ctx.System.Tag == null) + await ctx.Reply(noTagSetMessage); + else + await ctx.Reply($"Your current system tag is {ctx.System.Tag.AsCode()}. To change it, type `pk;s tag `. To clear it, type `pk;s tag -clear`."); + return; + } if (await ctx.MatchClear("your system's tag")) {