mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: move scheduled tasks to separate project
This commit is contained in:
parent
362770eef0
commit
3bc451eb4b
13 changed files with 1560 additions and 42 deletions
|
|
@ -10,8 +10,6 @@ namespace PluralKit.Bot
|
|||
{
|
||||
public class CommandMessageService
|
||||
{
|
||||
private static readonly Duration CommandMessageRetention = Duration.FromHours(24);
|
||||
|
||||
private readonly IDatabase _db;
|
||||
private readonly ModelRepository _repo;
|
||||
private readonly IClock _clock;
|
||||
|
|
@ -35,16 +33,5 @@ namespace PluralKit.Bot
|
|||
{
|
||||
return await _repo.GetCommandMessage(messageId);
|
||||
}
|
||||
|
||||
public async Task CleanupOldMessages()
|
||||
{
|
||||
var deleteThresholdInstant = _clock.GetCurrentInstant() - CommandMessageRetention;
|
||||
var deleteThresholdSnowflake = DiscordUtils.InstantToSnowflake(deleteThresholdInstant);
|
||||
|
||||
var deletedRows = await _repo.DeleteCommandMessagesBefore(deleteThresholdSnowflake);
|
||||
|
||||
_logger.Information("Pruned {DeletedRows} command messages older than retention {Retention} (older than {DeleteThresholdInstant} / {DeleteThresholdSnowflake})",
|
||||
deletedRows, CommandMessageRetention, deleteThresholdInstant, deleteThresholdSnowflake);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue