@@ -184,7 +184,7 @@ async def note(self, message):
184
184
)
185
185
186
186
187
- async def reply (self , message ):
187
+ async def reply (self , message , anonymous = False ):
188
188
if not message .content and not message .attachments :
189
189
raise commands .UserInputError
190
190
if all (not g .get_member (self .id ) for g in self .bot .guilds ):
@@ -196,13 +196,14 @@ async def reply(self, message):
196
196
197
197
tasks = [
198
198
# in thread channel
199
- self .send (message , self .channel , from_mod = True ),
199
+ self .send (message , destination = self .channel , from_mod = True , anonymous = True ),
200
200
# to user
201
- self .send (message , self .recipient , from_mod = True )
201
+ self .send (message , destination = self .recipient , from_mod = True , anonymous = True )
202
202
]
203
203
204
+
204
205
self .bot .loop .create_task (
205
- self .bot .modmail_api .append_log (message , self .channel .id )
206
+ self .bot .modmail_api .append_log (message , self .channel .id , type = 'anonymous' if anonymous else 'thread_message' )
206
207
)
207
208
208
209
if self .close_task is not None :
@@ -215,7 +216,7 @@ async def reply(self, message):
215
216
216
217
await asyncio .gather (* tasks )
217
218
218
- async def send (self , message , destination = None , from_mod = False , note = False ):
219
+ async def send (self , message , destination = None , from_mod = False , note = False , anonymous = False ):
219
220
if self .close_task is not None :
220
221
# cancel closing if a thread message is sent.
221
222
await self .cancel_closure ()
@@ -244,10 +245,21 @@ async def send(self, message, destination=None, from_mod=False, note=False):
244
245
245
246
# store message id in hidden url
246
247
if not note :
247
- em .set_author (name = author ,
248
- icon_url = author .avatar_url ,
248
+
249
+ if anonymous and from_mod and not isinstance (destination , discord .TextChannel ):
250
+ # Anonymously sending to the user.
251
+ name = self .bot .config .get ('anon_username' , self .bot .config .get ('mod_tag' , 'Moderator' ))
252
+ avatar_url = self .bot .config .get ('anon_avatar_url' , self .bot .guild .icon_url )
253
+ else :
254
+ # Normal message
255
+ name = str (author )
256
+ avatar_url = author .avatar_url
257
+
258
+ em .set_author (name = name ,
259
+ icon_url = avatar_url ,
249
260
url = message .jump_url )
250
261
else :
262
+ # Special note messages
251
263
em .set_author (
252
264
name = f'Note ({ author .name } )' ,
253
265
icon_url = system_avatar_url ,
@@ -301,7 +313,13 @@ def is_image_url(u, _):
301
313
302
314
if from_mod :
303
315
em .color = self .bot .mod_color
304
- em .set_footer (text = self .bot .config .get ('mod_tag' , 'Moderator' ))
316
+ if anonymous and isinstance (destination , discord .TextChannel ): # Anonymous reply sent in thread channel
317
+ em .set_footer (text = 'Anonymous Reply' )
318
+ elif not anonymous :
319
+ em .set_footer (text = self .bot .config .get ('mod_tag' , 'Moderator' )) # Normal messages
320
+ else :
321
+ em .set_footer (text = '\u200b ' ) # Anonymous reply sent to user
322
+
305
323
elif note :
306
324
em .color = discord .Color .blurple ()
307
325
else :
0 commit comments