aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-07-26 15:31:55 +0100
committerGravatar Chris Lovering <[email protected]>2021-07-26 15:31:55 +0100
commit02b3c8af0268239050d52db0becd856bc8ab9863 (patch)
treeeb5368ca3fc2c8847fab488bfaed3ae5d137c9d1
parentUpdate _get_messages_from_channels return type (diff)
Make is_older_than_14d a static method
-rw-r--r--bot/exts/utils/clean.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/bot/exts/utils/clean.py b/bot/exts/utils/clean.py
index 529dd9ee6..a1a9eafe4 100644
--- a/bot/exts/utils/clean.py
+++ b/bot/exts/utils/clean.py
@@ -42,6 +42,18 @@ class Clean(Cog):
"""Get currently loaded ModLog cog instance."""
return self.bot.get_cog("ModLog")
+ @staticmethod
+ def is_older_than_14d(message: Message) -> bool:
+ """
+ Precisely checks if message is older than 14 days, bulk deletion limit.
+
+ Inspired by how purge works internally.
+ Comparison on message age could possibly be less accurate which in turn would resort in problems
+ with message deletion if said messages are very close to the 14d mark.
+ """
+ two_weeks_old_snowflake = int((time.time() - 14 * 24 * 60 * 60) * 1000.0 - 1420070400000) << 22
+ return message.id < two_weeks_old_snowflake
+
async def _delete_messages_individually(self, messages: List[Message]) -> None:
for message in messages:
# Ensure that deletion was not canceled
@@ -105,17 +117,6 @@ class Clean(Cog):
return message_mappings, message_ids
- def is_older_than_14d(self, message: Message) -> bool:
- """
- Precisely checks if message is older than 14 days, bulk deletion limit.
-
- Inspired by how purge works internally.
- Comparison on message age could possibly be less accurate which in turn would resort in problems
- with message deletion if said messages are very close to the 14d mark.
- """
- two_weeks_old_snowflake = int((time.time() - 14 * 24 * 60 * 60) * 1000.0 - 1420070400000) << 22
- return message.id < two_weeks_old_snowflake
-
async def _clean_messages(
self,
amount: int,