Skip to content

Commit f21b9c0

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

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

core/thread.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,27 @@ async def snooze(self, moderator=None, command_used=None):
155155
"attachments": [a.url for a in m.attachments],
156156
"embeds": [e.to_dict() for e in m.embeds],
157157
"created_at": m.created_at.isoformat(),
158-
# Only use 'mod_only' if this is an internal note (note command)
158+
# Only use 'mod_only' if this is an internal note (note command), safe check for embed author
159159
"type": (
160160
"mod_only"
161-
if m.embeds and hasattr(m.embeds[0], 'author') and (
162-
getattr(m.embeds[0].author, 'name', '').startswith('Note') or
163-
getattr(m.embeds[0].author, 'name', '').startswith('Persistent Note')
161+
if (
162+
m.embeds
163+
and getattr(m.embeds[0], 'author', None)
164+
and (
165+
getattr(m.embeds[0].author, 'name', '').startswith('Note') or
166+
getattr(m.embeds[0].author, 'name', '').startswith('Persistent Note')
167+
)
164168
)
165169
else None
166170
),
167171
"author_name": getattr(m.author, "name", None),
168172
}
169173
async for m in channel.history(limit=None, oldest_first=True)
170-
# Only include if not already internal/note
174+
# Only include if not already internal/note, safe check for embed author
171175
if not (
172-
m.embeds and hasattr(m.embeds[0], 'author') and (
176+
m.embeds
177+
and getattr(m.embeds[0], 'author', None)
178+
and (
173179
getattr(m.embeds[0].author, 'name', '').startswith('Note') or
174180
getattr(m.embeds[0].author, 'name', '').startswith('Persistent Note')
175181
)

0 commit comments

Comments
 (0)