Skip to content

Commit f58ea05

Browse files
committed
added modmail reaction
1 parent 12ee4a4 commit f58ea05

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

cogs/modmail.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,24 @@ async def _queue_pending_message(self, user_id: int, message: discord.Message):
126126
messages.append({
127127
'content': message.content or '',
128128
'attachments': attachment_payloads,
129+
'source_message_id': message.id,
130+
'source_channel_id': message.channel.id,
129131
'created_at': datetime.utcnow().isoformat(),
130132
})
131133

134+
async def _react_dm_message_success(self, channel_id: int, message_id: int):
135+
try:
136+
ch = self.bot.get_channel(int(channel_id))
137+
if ch is None:
138+
ch = await self.bot.fetch_channel(int(channel_id))
139+
if not isinstance(ch, (discord.DMChannel, discord.PartialMessageable)):
140+
return
141+
msg = await ch.fetch_message(int(message_id))
142+
await msg.add_reaction("✅")
143+
except Exception:
144+
# Best-effort only.
145+
return
146+
132147
def _pending_to_discord_files(self, queued_attachments: list[dict]) -> tuple[list[discord.File], bool]:
133148
files: list[discord.File] = []
134149
had_skipped = False
@@ -295,6 +310,12 @@ async def _start_new_session_and_flush_pending(
295310
if files:
296311
send_kwargs['files'] = files
297312
await webhook.send(**send_kwargs)
313+
314+
# React to the original DM message once forwarded.
315+
src_mid = qm.get('source_message_id')
316+
src_cid = qm.get('source_channel_id')
317+
if src_mid and src_cid:
318+
await self._react_dm_message_success(int(src_cid), int(src_mid))
298319
except Exception as e:
299320
await thread.send(f"Failed to relay queued message from user: {e}")
300321
raise
@@ -536,6 +557,10 @@ async def handle_dm_message(self, message: discord.Message):
536557
thread=thread,
537558
files=files
538559
)
560+
try:
561+
await message.add_reaction("✅")
562+
except Exception:
563+
pass
539564
except Exception as e:
540565
if thread is not None:
541566
await thread.send(f"Failed to relay message from user: {e}")

0 commit comments

Comments
 (0)