using System.Collections.Concurrent;
using GmRelay.Shared.Platform;

namespace GmRelay.DiscordBot.Infrastructure.Discord;

public sealed class DiscordInteractionReplyCache
{
    private readonly ConcurrentDictionary<string, PlatformInteractionReply> replies = new(StringComparer.Ordinal);

    public void Store(PlatformInteractionReply reply) =>
        replies[reply.InteractionId] = reply;

    public PlatformInteractionReply? Take(string interactionId) =>
        replies.TryRemove(interactionId, out var reply)
            ? reply
            : null;
}
