PluralKit/PluralKit.Bot/Services/CommandMessageService.cs

35 lines
984 B
C#
Raw Normal View History

2020-10-23 10:18:28 +00:00
using NodaTime;
using PluralKit.Core;
using Serilog;
namespace PluralKit.Bot;
2021-08-27 15:03:47 +00:00
public class CommandMessageService
{
private readonly IClock _clock;
private readonly IDatabase _db;
private readonly ILogger _logger;
private readonly ModelRepository _repo;
2020-10-23 10:18:28 +00:00
public CommandMessageService(IDatabase db, ModelRepository repo, IClock clock, ILogger logger)
{
_db = db;
_repo = repo;
_clock = clock;
_logger = logger.ForContext<CommandMessageService>();
}
2020-10-23 10:18:28 +00:00
public async Task RegisterMessage(ulong messageId, ulong channelId, ulong authorId)
{
_logger.Debug(
"Registering command response {MessageId} from author {AuthorId} in {ChannelId}",
messageId, authorId, channelId
);
await _repo.SaveCommandMessage(messageId, channelId, authorId);
2020-10-23 10:18:28 +00:00
}
public async Task<CommandMessage?> GetCommandMessage(ulong messageId) =>
await _repo.GetCommandMessage(messageId);
2020-10-23 10:18:28 +00:00
}