Skip to content

Commit bd7c4c2

Browse files
authored
Update thread.py
Signed-off-by: lorenzo132 <[email protected]>
1 parent f21b9c0 commit bd7c4c2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/thread.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,18 @@ async def snooze(self, moderator=None, command_used=None):
139139
channel = self.channel
140140
if not isinstance(channel, discord.TextChannel):
141141
return False
142-
# Save channel info
142+
# Ensure self.log_key is set before snoozing
143+
if not self.log_key:
144+
# Try to fetch from DB using channel_id
145+
log_entry = await self.bot.api.get_log(self.channel.id)
146+
if log_entry and 'key' in log_entry:
147+
self.log_key = log_entry['key']
148+
# Fallback: try by recipient id
149+
elif hasattr(self, 'id'):
150+
log_entry = await self.bot.api.get_log(str(self.id))
151+
if log_entry and 'key' in log_entry:
152+
self.log_key = log_entry['key']
153+
143154
self.snooze_data = {
144155
"category_id": channel.category_id,
145156
"position": channel.position,
@@ -236,7 +247,7 @@ async def restore_from_snooze(self):
236247
reason="Thread unsnoozed/restored",
237248
)
238249
self._channel = channel
239-
# Restore the log_key from snooze_data (preserve log continuity)
250+
# Strictly restore the log_key from snooze_data (never create a new one)
240251
self.log_key = self.snooze_data.get("log_key")
241252
# Replay messages
242253
for msg in self.snooze_data["messages"]:

0 commit comments

Comments
 (0)