feat: store edit command message ID in redis

This commit is contained in:
sam 2024-08-16 16:10:55 +02:00 committed by Iris System
parent 4ffaed510a
commit aa04124639

View file

@ -39,11 +39,12 @@ public class ProxiedMessage
private readonly WebhookExecutorService _webhookExecutor; private readonly WebhookExecutorService _webhookExecutor;
private readonly ProxyService _proxy; private readonly ProxyService _proxy;
private readonly LastMessageCacheService _lastMessageCache; private readonly LastMessageCacheService _lastMessageCache;
private readonly RedisService _redisService;
public ProxiedMessage(EmbedService embeds, public ProxiedMessage(EmbedService embeds,
DiscordApiClient rest, IMetrics metrics, ModelRepository repo, ProxyService proxy, DiscordApiClient rest, IMetrics metrics, ModelRepository repo, ProxyService proxy,
WebhookExecutorService webhookExecutor, LogChannelService logChannel, IDiscordCache cache, WebhookExecutorService webhookExecutor, LogChannelService logChannel, IDiscordCache cache,
LastMessageCacheService lastMessageCache) LastMessageCacheService lastMessageCache, RedisService redisService)
{ {
_embeds = embeds; _embeds = embeds;
_rest = rest; _rest = rest;
@ -54,6 +55,7 @@ public class ProxiedMessage
_metrics = metrics; _metrics = metrics;
_proxy = proxy; _proxy = proxy;
_lastMessageCache = lastMessageCache; _lastMessageCache = lastMessageCache;
_redisService = redisService;
} }
public async Task ReproxyMessage(Context ctx) public async Task ReproxyMessage(Context ctx)
@ -221,6 +223,8 @@ public class ProxiedMessage
if (ctx.Guild == null) if (ctx.Guild == null)
await _rest.CreateReaction(ctx.Channel.Id, ctx.Message.Id, new Emoji { Name = Emojis.Success }); await _rest.CreateReaction(ctx.Channel.Id, ctx.Message.Id, new Emoji { Name = Emojis.Success });
await _redisService.SetOriginalMid(ctx.Message.Id, editedMsg.Id);
if ((await ctx.BotPermissions).HasFlag(PermissionSet.ManageMessages)) if ((await ctx.BotPermissions).HasFlag(PermissionSet.ManageMessages))
await _rest.DeleteMessage(ctx.Channel.Id, ctx.Message.Id); await _rest.DeleteMessage(ctx.Channel.Id, ctx.Message.Id);