move classes around, name caches more consistently, add more caches
This commit is contained in:
parent
e86b37ce2a
commit
e17dcf90a1
30 changed files with 443 additions and 51 deletions
|
|
@ -0,0 +1,27 @@
|
|||
using Catalogger.Backend.Cache;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||
using Remora.Discord.Gateway.Responders;
|
||||
using Remora.Results;
|
||||
|
||||
namespace Catalogger.Backend.Bot.Responders.Guilds;
|
||||
|
||||
public class GuildMembersChunkResponder(ILogger logger, IMemberCache memberCache) : IResponder<IGuildMembersChunk>
|
||||
{
|
||||
private readonly ILogger _logger = logger.ForContext<GuildMembersChunkResponder>();
|
||||
|
||||
public async Task<Result> RespondAsync(IGuildMembersChunk evt, CancellationToken ct = default)
|
||||
{
|
||||
_logger.Debug("Received chunk {ChunkIndex} / {ChunkCount} for guild {GuildId}", evt.ChunkIndex + 1,
|
||||
evt.ChunkCount, evt.GuildID);
|
||||
|
||||
await memberCache.SetManyAsync(evt.GuildID, evt.Members);
|
||||
|
||||
if (evt.ChunkIndex == evt.ChunkCount - 1)
|
||||
{
|
||||
_logger.Debug("Final chunk for guild {GuildId} received, marking as cached", evt.GuildID);
|
||||
await memberCache.MarkAsCachedAsync(evt.GuildID);
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue