From 8cad05ccda9038da1940226d61895c8bd0e35177 Mon Sep 17 00:00:00 2001 From: dawn <90008@gaze.systems> Date: Tue, 20 Jan 2026 00:04:22 +0300 Subject: [PATCH] fix edit message requiring new_content param, fix both edit and rp not using referenced message --- PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs | 6 +++--- PluralKit.Bot/Commands/Checks.cs | 5 ++--- PluralKit.Bot/Commands/Message.cs | 6 +++--- crates/command_definitions/src/message.rs | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs index 730b4e8d..d04babb7 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextArgumentsExt.cs @@ -6,11 +6,11 @@ namespace PluralKit.Bot; public static class ContextArgumentsExt { - public static (ulong? messageId, ulong? channelId) GetRepliedTo(this Context ctx) + public static Message.Reference? GetRepliedTo(this Context ctx) { if (ctx.Message.Type == Message.MessageType.Reply && ctx.Message.MessageReference?.MessageId != null) - return (ctx.Message.MessageReference.MessageId, ctx.Message.MessageReference.ChannelId); - return (null, null); + return ctx.Message.MessageReference; + return null; } public static (ulong? messageId, ulong? channelId) ParseMessage(this Context ctx, string maybeMessageRef, bool parseRawMessageId) diff --git a/PluralKit.Bot/Commands/Checks.cs b/PluralKit.Bot/Commands/Checks.cs index 26a53354..8134cbba 100644 --- a/PluralKit.Bot/Commands/Checks.cs +++ b/PluralKit.Bot/Commands/Checks.cs @@ -167,9 +167,8 @@ public class Checks var failedToGetMessage = "Could not find a valid message to check, was not able to fetch the message, or the message was not sent by you."; - var (messageId, channelId) = ctx.GetRepliedTo(); - if (messageReference != null) - (messageId, channelId) = (messageReference.MessageId, messageReference.ChannelId); + messageReference = ctx.GetRepliedTo(); + var (messageId, channelId) = (messageReference?.MessageId, messageReference?.ChannelId); if (messageId == null || channelId == null) throw new PKError(failedToGetMessage); diff --git a/PluralKit.Bot/Commands/Message.cs b/PluralKit.Bot/Commands/Message.cs index b7ac474c..4a73d92c 100644 --- a/PluralKit.Bot/Commands/Message.cs +++ b/PluralKit.Bot/Commands/Message.cs @@ -60,7 +60,7 @@ public class ProxiedMessage public async Task ReproxyMessage(Context ctx, Message.Reference? messageRef, PKMember target) { - var (msg, systemId) = await GetMessageToEdit(ctx, messageRef?.MessageId, ReproxyTimeout, true); + var (msg, systemId) = await GetMessageToEdit(ctx, messageRef?.MessageId ?? ctx.GetRepliedTo()?.MessageId, ReproxyTimeout, true); if (ctx.System.Id != systemId) throw new PKError("Can't reproxy a message sent by a different system."); @@ -91,9 +91,9 @@ public class ProxiedMessage } } - public async Task EditMessage(Context ctx, Message.Reference? messageRef, string newContent, bool useRegex, bool noSpace, bool append, bool prepend, bool clearEmbeds, bool clearAttachments) + public async Task EditMessage(Context ctx, Message.Reference? messageRef, string? newContent, bool useRegex, bool noSpace, bool append, bool prepend, bool clearEmbeds, bool clearAttachments) { - var (msg, systemId) = await GetMessageToEdit(ctx, messageRef?.MessageId, EditTimeout, false); + var (msg, systemId) = await GetMessageToEdit(ctx, messageRef?.MessageId ?? ctx.GetRepliedTo()?.MessageId, EditTimeout, false); if (ctx.System.Id != systemId) throw new PKError("Can't edit a message sent by a different system."); diff --git a/crates/command_definitions/src/message.rs b/crates/command_definitions/src/message.rs index 8531efd4..1f021b27 100644 --- a/crates/command_definitions/src/message.rs +++ b/crates/command_definitions/src/message.rs @@ -10,7 +10,7 @@ pub fn cmds() -> impl IntoIterator { let reproxy = ("reproxy", ["rp", "crimes", "crime"]); let edit = ("edit", ["e"]); - let new_content_param = Remainder(("new_content", OpaqueString)); + let new_content_param = Optional(Remainder(("new_content", OpaqueString))); let apply_edit = |cmd: Command| { cmd.flag(("append", ["a"])) .flag(("prepend", ["p"]))