@@ -138,7 +138,33 @@ async def snooze(self, moderator=None, command_used=None):
138
138
channel = self .channel
139
139
if not isinstance (channel , discord .TextChannel ):
140
140
return False
141
+
141
142
# Save channel info
143
+ def classify_message (m ):
144
+ msg_type = getattr (m , "type" , None )
145
+ # Detect mod-only messages: not the bot, not the thread recipient, and not a user message
146
+ if (
147
+ msg_type is None
148
+ and hasattr (m , "author" )
149
+ and m .author .id != self .bot .user .id
150
+ and (not self .recipient or m .author .id != self .recipient .id )
151
+ and hasattr (m .channel , "guild" )
152
+ and m .channel .guild is not None
153
+ ):
154
+ # Check if author is a moderator (manage_messages or administrator)
155
+ perms = m .channel .permissions_for (m .author )
156
+ if perms .manage_messages or perms .administrator :
157
+ msg_type = "mod_only"
158
+ return {
159
+ "author_id" : m .author .id ,
160
+ "content" : m .content ,
161
+ "attachments" : [a .url for a in m .attachments ],
162
+ "embeds" : [e .to_dict () for e in m .embeds ],
163
+ "created_at" : m .created_at .isoformat (),
164
+ "type" : msg_type ,
165
+ "author_name" : getattr (m .author , "name" , None ),
166
+ }
167
+
142
168
self .snooze_data = {
143
169
"category_id" : channel .category_id ,
144
170
"position" : channel .position ,
@@ -147,18 +173,7 @@ async def snooze(self, moderator=None, command_used=None):
147
173
"slowmode_delay" : channel .slowmode_delay ,
148
174
"nsfw" : channel .nsfw ,
149
175
"overwrites" : [(role .id , perm ._values ) for role , perm in channel .overwrites .items ()],
150
- "messages" : [
151
- {
152
- "author_id" : m .author .id ,
153
- "content" : m .content ,
154
- "attachments" : [a .url for a in m .attachments ],
155
- "embeds" : [e .to_dict () for e in m .embeds ],
156
- "created_at" : m .created_at .isoformat (),
157
- "type" : getattr (m , "type" , None ),
158
- "author_name" : getattr (m .author , "name" , None ),
159
- }
160
- async for m in channel .history (limit = None , oldest_first = True )
161
- ],
176
+ "messages" : [classify_message (m ) async for m in channel .history (limit = None , oldest_first = True )],
162
177
"snoozed_by" : getattr (moderator , "name" , None ) if moderator else None ,
163
178
"snooze_command" : command_used ,
164
179
}
0 commit comments