88import traceback
99import typing
1010import warnings
11- from datetime import timedelta
11+ from datetime import timedelta , datetime , timezone
1212from types import SimpleNamespace
1313
1414import isodate
@@ -130,7 +130,7 @@ def cancelled(self, flag: bool):
130130 for i in self .wait_tasks :
131131 i .cancel ()
132132
133- async def snooze (self , moderator = None , command_used = None ):
133+ async def snooze (self , moderator = None , command_used = None , snooze_for = None ):
134134 """
135135 Save channel/category/position/messages to DB, mark as snoozed, delete channel.
136136 """
@@ -151,6 +151,7 @@ async def snooze(self, moderator=None, command_used=None):
151151 if log_entry and "key" in log_entry :
152152 self .log_key = log_entry ["key" ]
153153
154+ now = datetime .now (timezone .utc )
154155 self .snooze_data = {
155156 "category_id" : channel .category_id ,
156157 "position" : channel .position ,
@@ -166,7 +167,6 @@ async def snooze(self, moderator=None, command_used=None):
166167 "attachments" : [a .url for a in m .attachments ],
167168 "embeds" : [e .to_dict () for e in m .embeds ],
168169 "created_at" : m .created_at .isoformat (),
169- # Only use 'mod_only' if this is an internal note (note command), safe check for embed author
170170 "type" : (
171171 "mod_only"
172172 if (
@@ -182,7 +182,6 @@ async def snooze(self, moderator=None, command_used=None):
182182 "author_name" : getattr (m .author , "name" , None ),
183183 }
184184 async for m in channel .history (limit = None , oldest_first = True )
185- # Only include if not already internal/note, safe check for embed author
186185 if not (
187186 m .embeds
188187 and getattr (m .embeds [0 ], "author" , None )
@@ -195,7 +194,9 @@ async def snooze(self, moderator=None, command_used=None):
195194 ],
196195 "snoozed_by" : getattr (moderator , "name" , None ) if moderator else None ,
197196 "snooze_command" : command_used ,
198- "log_key" : self .log_key , # Preserve the log_key
197+ "log_key" : self .log_key ,
198+ "snooze_start" : now .isoformat (),
199+ "snooze_for" : snooze_for ,
199200 }
200201 self .snoozed = True
201202 # Save to DB (robust: try recipient.id, then channel_id)
@@ -289,19 +290,19 @@ async def restore_from_snooze(self):
289290 if self .log_key :
290291 result = await self .bot .api .logs .update_one (
291292 {"key" : self .log_key },
292- {"$set" : {"snoozed" : False , " channel_id" : str (channel .id )}, "$unset" : {"snooze_data" : "" }},
293+ {"$set" : {"channel_id" : str (channel .id )}, "$unset" : {"snoozed" : "" , "snooze_data" : "" }},
293294 )
294295 else :
295296 result = await self .bot .api .logs .update_one (
296297 {"recipient.id" : str (self .id )},
297- {"$set" : {"snoozed" : False , " channel_id" : str (channel .id )}, "$unset" : {"snooze_data" : "" }},
298+ {"$set" : {"channel_id" : str (channel .id )}, "$unset" : {"snoozed" : "" , "snooze_data" : "" }},
298299 )
299300 if result .modified_count == 0 :
300301 result = await self .bot .api .logs .update_one (
301302 {"channel_id" : str (channel .id )},
302303 {
303- "$set" : {"snoozed" : False , " channel_id" : str (channel .id )},
304- "$unset" : {"snooze_data" : "" },
304+ "$set" : {"channel_id" : str (channel .id )},
305+ "$unset" : {"snoozed" : "" , " snooze_data" : "" },
305306 },
306307 )
307308 import logging
0 commit comments