Skip to content

Commit

Permalink
Skip messages older than 14 days on clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoertm committed Nov 6, 2023
1 parent ec9ec39 commit 8ce9238
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Clubber.Domain/Modules/Moderator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public async Task Clear()
const int messagesToSkip = 1;
IEnumerable<IMessage> lastHundredMessages = await currentTextChannel.GetMessagesAsync().FlattenAsync();
IEnumerable<IMessage> messagesToDelete = lastHundredMessages
.Where(x => (DateTimeOffset.UtcNow - x.Timestamp).TotalDays <= 14)
.OrderByDescending(m => m.CreatedAt)
.SkipLast(messagesToSkip);

Expand Down

0 comments on commit 8ce9238

Please sign in to comment.