@@ -154,26 +154,27 @@ async def snooze(self, moderator=None, command_used=None):
154154 "attachments" : [a .url for a in m .attachments ],
155155 "embeds" : [e .to_dict () for e in m .embeds ],
156156 "created_at" : m .created_at .isoformat (),
157- "type" : getattr (m , ' type' , None ),
158- "author_name" : getattr (m .author , ' name' , None ),
157+ "type" : getattr (m , " type" , None ),
158+ "author_name" : getattr (m .author , " name" , None ),
159159 }
160160 async for m in channel .history (limit = None , oldest_first = True )
161161 ],
162- ' snoozed_by' : getattr (moderator , ' name' , None ) if moderator else None ,
163- ' snooze_command' : command_used ,
162+ " snoozed_by" : getattr (moderator , " name" , None ) if moderator else None ,
163+ " snooze_command" : command_used ,
164164 }
165165 self .snoozed = True
166166 # Save to DB (robust: try recipient.id, then channel_id)
167167 result = await self .bot .api .logs .update_one (
168- {' recipient.id' : str (self .id )},
169- {' $set' : {' snoozed' : True , ' snooze_data' : self .snooze_data }},
168+ {" recipient.id" : str (self .id )},
169+ {" $set" : {" snoozed" : True , " snooze_data" : self .snooze_data }},
170170 )
171171 if result .modified_count == 0 and self .channel :
172172 result = await self .bot .api .logs .update_one (
173- {' channel_id' : str (self .channel .id )},
174- {' $set' : {' snoozed' : True , ' snooze_data' : self .snooze_data }},
173+ {" channel_id" : str (self .channel .id )},
174+ {" $set" : {" snoozed" : True , " snooze_data" : self .snooze_data }},
175175 )
176176 import logging
177+
177178 logging .info (f"[SNOOZE] DB update result: { result .modified_count } " )
178179 # Delete channel
179180 await channel .delete (reason = "Thread snoozed by moderator" )
@@ -186,11 +187,14 @@ async def restore_from_snooze(self):
186187 """
187188 if not self .snooze_data or not isinstance (self .snooze_data , dict ):
188189 import logging
189- logging .warning (f"[UNSNOOZE] Tried to restore thread { self .id } but snooze_data is None or not a dict." )
190+
191+ logging .warning (
192+ f"[UNSNOOZE] Tried to restore thread { self .id } but snooze_data is None or not a dict."
193+ )
190194 return False
191195 # Now safe to access self.snooze_data
192- snoozed_by = self .snooze_data .get (' snoozed_by' )
193- snooze_command = self .snooze_data .get (' snooze_command' )
196+ snoozed_by = self .snooze_data .get (" snoozed_by" )
197+ snooze_command = self .snooze_data .get (" snooze_command" )
194198 guild = self .bot .modmail_guild
195199 category = guild .get_channel (self .snooze_data ["category_id" ])
196200 overwrites = {}
@@ -210,18 +214,18 @@ async def restore_from_snooze(self):
210214 )
211215 self ._channel = channel
212216 # Replay messages
213- for msg in self .snooze_data [' messages' ]:
214- author = self .bot .get_user (msg [' author_id' ]) or await self .bot .get_or_fetch_user (msg [' author_id' ])
215- content = msg [' content' ]
216- embeds = [discord .Embed .from_dict (e ) for e in msg .get (' embeds' , []) if e ]
217- attachments = msg .get (' attachments' , [])
218- msg_type = msg .get (' type' )
217+ for msg in self .snooze_data [" messages" ]:
218+ author = self .bot .get_user (msg [" author_id" ]) or await self .bot .get_or_fetch_user (msg [" author_id" ])
219+ content = msg [" content" ]
220+ embeds = [discord .Embed .from_dict (e ) for e in msg .get (" embeds" , []) if e ]
221+ attachments = msg .get (" attachments" , [])
222+ msg_type = msg .get (" type" )
219223 # Only send if there is content, embeds, or attachments
220224 if not content and not embeds and not attachments :
221225 continue # Skip empty messages
222226 # Format internal/system messages as 'username: textcontent'
223- if msg_type in (' internal' , ' note' , ' system' ):
224- username = msg .get (' author_name' ) or (getattr (author , ' name' , None )) or ' Unknown'
227+ if msg_type in (" internal" , " note" , " system" ):
228+ username = msg .get (" author_name" ) or (getattr (author , " name" , None )) or " Unknown"
225229 formatted = f"{ username } : { content } " if content else username
226230 await channel .send (formatted )
227231 else :
@@ -232,29 +236,30 @@ async def restore_from_snooze(self):
232236 self .snooze_data = None
233237 # Update channel_id in DB and clear snooze_data (robust: try recipient.id, then channel_id)
234238 result = await self .bot .api .logs .update_one (
235- {' recipient.id' : str (self .id )},
236- {' $set' : {' snoozed' : False , ' channel_id' : str (channel .id )}, ' $unset' : {' snooze_data' : "" }},
239+ {" recipient.id" : str (self .id )},
240+ {" $set" : {" snoozed" : False , " channel_id" : str (channel .id )}, " $unset" : {" snooze_data" : "" }},
237241 )
238242 if result .modified_count == 0 :
239243 result = await self .bot .api .logs .update_one (
240- {' channel_id' : str (channel .id )},
241- {' $set' : {' snoozed' : False , ' channel_id' : str (channel .id )}, ' $unset' : {' snooze_data' : "" }},
244+ {" channel_id" : str (channel .id )},
245+ {" $set" : {" snoozed" : False , " channel_id" : str (channel .id )}, " $unset" : {" snooze_data" : "" }},
242246 )
243247 import logging
248+
244249 logging .info (f"[UNSNOOZE] DB update result: { result .modified_count } " )
245250 # Notify in the configured channel
246251 notify_channel = self .bot .config .get ("unsnooze_notify_channel" ) or "thread"
247252 notify_text = self .bot .config .get ("unsnooze_text" ) or "This thread has been unsnoozed and restored."
248- if notify_channel == ' thread' :
253+ if notify_channel == " thread" :
249254 await channel .send (notify_text )
250255 else :
251256 ch = self .bot .get_channel (int (notify_channel ))
252257 if ch :
253258 await ch .send (f"Thread for user <@{ self .id } > has been unsnoozed and restored." )
254259 # Show who ran the snooze command and the command used
255260 # Use snooze_data_for_notify to avoid accessing self.snooze_data after it is set to None
256- snoozed_by = snooze_data_for_notify .get (' snoozed_by' ) if snooze_data_for_notify else None
257- snooze_command = snooze_data_for_notify .get (' snooze_command' ) if snooze_data_for_notify else None
261+ snoozed_by = snooze_data_for_notify .get (" snoozed_by" ) if snooze_data_for_notify else None
262+ snooze_command = snooze_data_for_notify .get (" snooze_command" ) if snooze_data_for_notify else None
258263 if snoozed_by or snooze_command :
259264 info = f"Snoozed by: { snoozed_by or 'Unknown' } | Command: { snooze_command or '?snooze' } "
260265 await channel .send (info )
0 commit comments