Skip to content

Commit 51572a0

Browse files
committed
modmail webhooks
1 parent 67bc780 commit 51572a0

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

cogs/modmail.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ async def handle_dm_message(self, message: discord.Message):
160160
await self._send_dm_safe(message.author, embed=discord.Embed(
161161
title="ModMail Started",
162162
description="A session has been started with the moderators. Messages you send here will be forwarded to them.",
163-
color=discord.Color.green()
163+
color=discord.Color.default()
164164
))
165165

166166
# Send initial message via webhook
@@ -249,8 +249,12 @@ async def handle_thread_reply(self, message: discord.Message):
249249

250250
try:
251251
files = [await f.to_file() for f in message.attachments]
252-
embed = discord.Embed(description=message.content, color=discord.Color.green())
253-
embed.set_author(name=message.author.display_name, icon_url=message.author.display_avatar.url)
252+
embed = discord.Embed(
253+
title="A moderator has replied",
254+
description=message.content,
255+
color=discord.Color.from_str("#00ff00")
256+
)
257+
# embed.set_author(name=message.author.display_name, icon_url=message.author.display_avatar.url)
254258
await self._send_dm_safe(user, embed=embed, files=files)
255259

256260
self.modmail_sessions[session_user_id]['last_activity'] = datetime.utcnow().isoformat()
@@ -285,13 +289,33 @@ async def close_session(self, ctx):
285289
await user.send(embed=discord.Embed(
286290
title="Session Closed",
287291
description="This modmail session has been closed by a moderator.",
288-
color=discord.Color.red()
292+
color=discord.Color.default()
289293
))
290294
except:
291295
pass
296+
297+
# Log closure to main channel
298+
if self.modmail_channel_id:
299+
main_channel = self.bot.get_channel(self.modmail_channel_id)
300+
if main_channel and isinstance(main_channel, discord.TextChannel):
301+
try:
302+
log_embed = discord.Embed(
303+
title="📪 ModMail Closed",
304+
description=f"**User:** <@{session_user_id}> (`{session_user_id}`)\n**Thread:** {ctx.channel.mention}\n**Closed By:** {ctx.author.mention}",
305+
color=discord.Color.from_str("#ff0000"),
306+
timestamp=datetime.utcnow()
307+
)
308+
await main_channel.send(embed=log_embed)
309+
except Exception as e:
310+
logger.error(f"Failed to send modmail close log: {e}")
292311

293312
await ctx.send("Session closed. Archiving thread...")
294-
await ctx.channel.edit(archived=True, locked=True)
313+
314+
new_name = f"🔒 {ctx.channel.name}"
315+
if len(new_name) > 100:
316+
new_name = new_name[:100]
317+
318+
await ctx.channel.edit(name=new_name, archived=True, locked=True)
295319

296320
@tasks.loop(minutes=1)
297321
async def cleanup_inactive_sessions(self):
@@ -332,7 +356,7 @@ async def cleanup_inactive_sessions(self):
332356
await user.send(embed=discord.Embed(
333357
title="Session Closed",
334358
description="Modmail session timed out due to inactivity.",
335-
color=discord.Color.red()
359+
color=discord.Color.default()
336360
))
337361
except:
338362
pass

0 commit comments

Comments
 (0)