ktwrd / ktwrd/XeniaBot

Messages older than 2 weeks can't be purged with `/purge`

Open
#49 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

When purging messages older than 2 weeks, the following exception would be thrown:
```
System.ArgumentOutOfRangeException: Messages must be younger than two weeks old. (Parameter 'MessageIds')
at Discord.Preconditions.YoungerThanTwoWeeks(UInt64[] collection, String name)
at Discord.API.DiscordRestApiClient.DeleteMessagesAsync(UInt64 channelId, DeleteMessagesParams args, RequestOptions options)
at Discord.Rest.ChannelHelper.DeleteMessagesAsync(ITextChannel channel, BaseDiscordClient client, IEnumerable`1 messageIds, RequestOptions options)
at XeniaBot.Core.Modules.ModerationModule.PurgeMessages(Int32 count, IChannel channel) in /src/XeniaBot.Core/Modules/ModerationModule.cs:line 335
```
https://github.com/ktwrd/XeniaBot/blob/a9ba5d1264c1c9fb25c5dcf6825c0d1be827d91a/XeniaBot.Core/Modules/ModerationModule.cs#L335

This should be fixed so mods can use the `/purge` command. But this needs to be done once BanSync PostgreSQL data migration has been deployed & ran.

https://docs.discord.com/developers/resources/message#bulk-delete-messages

Might need to implement a queue for this operation in a channel, since only 5 messages per second can be deleted.

Contributor guide

Open the contributing guide

Research direction

Start in XeniaBot.Core/Modules/ModerationModule.cs at line 335 and read Discord's bulk-delete message documentation. Confirm that the BanSync PostgreSQL migration has been deployed and run, then determine how /purge should handle messages older than two weeks and the five-per-second deletion limit. Done means moderators can purge those messages without the shown exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.