feat(bot): store command message info in redis

This commit is contained in:
spiral
2022-06-19 20:28:55 -04:00
parent 33b77470ee
commit 5c055871e3
6 changed files with 31 additions and 75 deletions

View File

@@ -2,6 +2,8 @@
using System.Text;
using System.Text.RegularExpressions;
using Autofac;
using Myriad.Builders;
using Myriad.Cache;
using Myriad.Extensions;
@@ -304,14 +306,14 @@ public class ProxiedMessage
private async Task DeleteCommandMessage(Context ctx, ulong messageId)
{
var message = await ctx.Repository.GetCommandMessage(messageId);
if (message == null)
var (authorId, channelId) = await ctx.Services.Resolve<CommandMessageService>().GetCommandMessage(messageId);
if (authorId == null)
throw Errors.MessageNotFound(messageId);
if (message.AuthorId != ctx.Author.Id)
if (authorId != ctx.Author.Id)
throw new PKError("You can only delete command messages queried by this account.");
await ctx.Rest.DeleteMessage(message.ChannelId, message.MessageId);
await ctx.Rest.DeleteMessage(channelId!.Value, messageId);
if (ctx.Guild != null)
await ctx.Rest.DeleteMessage(ctx.Message);