Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions bot/cogs/watchchannels/watchchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import dateutil.parser
import discord
from discord import Color, Embed, HTTPException, Message, errors
from discord import Color, DMChannel, Embed, HTTPException, Message, errors
from discord.ext.commands import Cog, Context

from bot.api import ResponseCodeError
Expand Down Expand Up @@ -273,7 +273,14 @@ async def send_header(self, msg: Message) -> None:

reason = self.watched_users[user_id]['reason']

embed = Embed(description=f"{msg.author.mention} in [#{msg.channel.name}]({msg.jump_url})")
if isinstance(msg.channel, DMChannel):
# If a watched user DMs the bot there won't be a channel name or jump URL
# This could technically include a GroupChannel but bot's can't be in those
message_jump = "via DM"
else:
message_jump = f"in [#{msg.channel.name}]({msg.jump_url})"

embed = Embed(description=f"{msg.author.mention} {message_jump}")
embed.set_footer(text=f"Added {time_delta} by {actor} | Reason: {reason}")

await self.webhook_send(embed=embed, username=msg.author.display_name, avatar_url=msg.author.avatar_url)
Expand Down