diff --git a/Myriad/Rest/DiscordApiClient.cs b/Myriad/Rest/DiscordApiClient.cs index 257b3be6..4612fd2c 100644 --- a/Myriad/Rest/DiscordApiClient.cs +++ b/Myriad/Rest/DiscordApiClient.cs @@ -54,7 +54,8 @@ namespace Myriad.Rest public Task DeleteMessage(ulong channelId, ulong messageId) => _client.Delete($"/channels/{channelId}/messages/{messageId}", ("DeleteMessage", channelId)); - + public Task DeleteMessage(Message message) => + _client.Delete($"/channels/{message.ChannelId}/messages/{message.Id}", ("DeleteMessage", message.ChannelId)); public Task CreateReaction(ulong channelId, ulong messageId, Emoji emoji) => _client.Put($"/channels/{channelId}/messages/{messageId}/reactions/{EncodeEmoji(emoji)}/@me", ("CreateReaction", channelId), null); diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index f418d784..6363c5e7 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -75,7 +75,7 @@ namespace PluralKit.Bot public static Command Export = new Command("export", "export", "Exports system information to a data file"); public static Command Help = new Command("help", "help", "Shows help information about PluralKit"); public static Command Explain = new Command("explain", "explain", "Explains the basics of systems and proxying"); - public static Command Message = new Command("message", "message ", "Looks up a proxied message"); + public static Command Message = new Command("message", "message [delete]", "Looks up a proxied message"); public static Command LogChannel = new Command("log channel", "log channel ", "Designates a channel to post proxied messages to"); public static Command LogChannelClear = new Command("log channel", "log channel -clear", "Clears the currently set log channel"); public static Command LogEnable = new Command("log enable", "log enable all| [channel 2] [channel 3...]", "Enables message logging in certain channels"); diff --git a/PluralKit.Bot/Commands/Misc.cs b/PluralKit.Bot/Commands/Misc.cs index 5f89c245..ad04c60a 100644 --- a/PluralKit.Bot/Commands/Misc.cs +++ b/PluralKit.Bot/Commands/Misc.cs @@ -222,6 +222,15 @@ namespace PluralKit.Bot { var message = await _db.Execute(c => _repo.GetMessage(c, messageId)); if (message == null) throw Errors.MessageNotFound(messageId); + if (ctx.Match("delete") || ctx.MatchFlag("delete")) + { + if (message.System.Id != ctx.System.Id) + throw new PKError("You can only delete your own messages."); + await ctx.Rest.DeleteMessage(message.Message.Channel, message.Message.Mid); + await ctx.Rest.DeleteMessage(ctx.Message); + return; + } + await ctx.Reply(embed: await _embeds.CreateMessageInfoEmbed(message)); } }