From 31a129dabfd8a3bab57b237b7da4e3062e6255b1 Mon Sep 17 00:00:00 2001 From: spiral Date: Fri, 21 Jan 2022 17:10:00 -0500 Subject: [PATCH] fix: check HasNext after matching message in EditMessage, use PKSyntaxError instead of PKError --- PluralKit.Bot/Commands/Message.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index ff5182df..596a5b0d 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -46,14 +46,14 @@ public class ProxiedMessage public async Task EditMessage(Context ctx) { - if (!ctx.HasNext()) - throw new PKSyntaxError("You need to include the message to edit in."); - var msg = await GetMessageToEdit(ctx); if (ctx.System.Id != msg.System?.Id) throw new PKError("Can't edit a message sent by a different system."); + if (!ctx.HasNext()) + throw new PKSyntaxError("You need to include the message to edit in."); + var newContent = ctx.RemainderOrNull().NormalizeLineEndSpacing(); var originalMsg = await _rest.GetMessageOrNull(msg.Message.Channel, msg.Message.Mid); @@ -96,15 +96,15 @@ public class ProxiedMessage if (msg == null) { if (ctx.Guild == null) - throw new PKError("You must use a message link to edit messages in DMs."); + throw new PKSyntaxError("You must use a message link to edit messages in DMs."); var recent = await FindRecentMessage(ctx); if (recent == null) - throw new PKError("Could not find a recent message to edit."); + throw new PKSyntaxError("Could not find a recent message to edit."); msg = await _repo.GetMessage(conn, recent.Mid); if (msg == null) - throw new PKError("Could not find a recent message to edit."); + throw new PKSyntaxError("Could not find a recent message to edit."); } if (msg.Message.Channel != ctx.Channel.Id)