@@ -2322,7 +2322,7 @@ async def snooze(self, ctx, *, duration: UserFriendlyTime = None):
23222322 - delete (default): deletes the channel and restores it later
23232323 - move: moves the channel to the configured snoozed category
23242324 Optionally specify a duration, e.g. 'snooze 2d' for 2 days.
2325- Uses config: max_snooze_time , snooze_title, snooze_text
2325+ Uses config: default_snooze_time , snooze_title, snooze_text
23262326 """
23272327 thread = ctx .thread
23282328 if thread .snoozed :
@@ -2331,20 +2331,20 @@ async def snooze(self, ctx, *, duration: UserFriendlyTime = None):
23312331 return
23322332 from core .time import ShortTime
23332333
2334- max_snooze = self .bot .config .get ("max_snooze_time " )
2335- if max_snooze is None :
2336- max_snooze = 604800
2334+ default_snooze = self .bot .config .get ("default_snooze_time " )
2335+ if default_snooze is None :
2336+ default_snooze = 604800
23372337 else :
23382338 try :
2339- max_snooze = int ((ShortTime (str (max_snooze )).dt - ShortTime ("0s" ).dt ).total_seconds ())
2339+ default_snooze = int ((ShortTime (str (default_snooze )).dt - ShortTime ("0s" ).dt ).total_seconds ())
23402340 except Exception :
2341- max_snooze = 604800
2341+ default_snooze = 604800
23422342 if duration :
23432343 snooze_for = int ((duration .dt - duration .now ).total_seconds ())
2344- if snooze_for > max_snooze :
2345- snooze_for = max_snooze
2344+ if snooze_for > default_snooze :
2345+ snooze_for = default_snooze
23462346 else :
2347- snooze_for = max_snooze
2347+ snooze_for = default_snooze
23482348
23492349 # Capacity pre-check: if behavior is move, ensure snoozed category has room (<49 channels)
23502350 behavior = (self .bot .config .get ("snooze_behavior" ) or "delete" ).lower ()
@@ -2425,11 +2425,18 @@ async def snooze(self, ctx, *, duration: UserFriendlyTime = None):
24252425 except Exception :
24262426 pass
24272427
2428- # Storing snooze_start and snooze_for in the log entry
2428+ # Store snooze_until timestamp for reliable auto-unsnooze
24292429 now = datetime .now (timezone .utc )
2430+ snooze_until = now + timedelta (seconds = snooze_for )
24302431 await self .bot .api .logs .update_one (
24312432 {"recipient.id" : str (thread .id )},
2432- {"$set" : {"snooze_start" : now .isoformat (), "snooze_for" : snooze_for }},
2433+ {
2434+ "$set" : {
2435+ "snooze_start" : now .isoformat (),
2436+ "snooze_for" : snooze_for ,
2437+ "snooze_until" : snooze_until .isoformat (),
2438+ }
2439+ },
24332440 )
24342441 embed = discord .Embed (
24352442 title = self .bot .config .get ("snooze_title" ) or "Thread Snoozed" ,
@@ -2557,24 +2564,17 @@ async def snooze_auto_unsnooze_task(self):
25572564 now = datetime .now (timezone .utc )
25582565 snoozed = await self .bot .api .logs .find ({"snoozed" : True }).to_list (None )
25592566 for entry in snoozed :
2560- start = entry .get ("snooze_start" )
2561- snooze_for = entry .get ("snooze_for" )
2562- if not start :
2563- continue
2564- start_dt = datetime .fromisoformat (start )
2565- if snooze_for is not None :
2566- duration = int (snooze_for )
2567- else :
2568- max_snooze = self .bot .config .get ("max_snooze_time" )
2569- if max_snooze is None :
2570- max_snooze = 604800
2571- duration = int (max_snooze )
2572- if (now - start_dt ).total_seconds () > duration :
2573- # Auto-unsnooze
2574- thread = await self .bot .threads .find (recipient_id = int (entry ["recipient" ]["id" ]))
2575- if thread and thread .snoozed :
2576- await thread .restore_from_snooze ()
2577- await asyncio .sleep (60 )
2567+ snooze_until = entry .get ("snooze_until" )
2568+ if snooze_until :
2569+ try :
2570+ until_dt = datetime .fromisoformat (snooze_until )
2571+ if now >= until_dt :
2572+ thread = await self .bot .threads .find (recipient_id = int (entry ["recipient" ]["id" ]))
2573+ if thread and thread .snoozed :
2574+ await thread .restore_from_snooze ()
2575+ except (ValueError , TypeError ):
2576+ pass
2577+ await asyncio .sleep (10 )
25782578
25792579 async def process_dm_modmail (self , message : discord .Message ) -> None :
25802580 # ... existing code ...
0 commit comments