Skip to content

Commit

Permalink
[ExtendedModLog] Try and mention inviters if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
TrustyJAID committed Aug 30, 2024
1 parent e6bbeef commit 63e8065
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extendedmodlog/eventmixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@ async def get_invite_link(self, member: discord.Member) -> str:
"https://discord.gg/{code}\nInvited by: {inviter}"
).format(
code=invite.code,
inviter=str(getattr(invite, "inviter", _("Widget Integration"))),
inviter=str(
getattr(invite.inviter, "mention", _("Widget Integration"))
),
)

if not possible_link:
Expand All @@ -679,8 +681,11 @@ async def get_invite_link(self, member: discord.Member) -> str:
# The invite link was on its last uses and subsequently
# deleted so we're fairly sure this was the one used
try:
if (inviter := guild.get_member(data["inviter"])) is None:
inviter = guild.get_member(data["inviter"])
if inviter is None:
inviter = await self.bot.fetch_user(data["inviter"])
if inviter is not None:
inviter = inviter.mention
except (discord.errors.NotFound, discord.errors.Forbidden):
inviter = _("Unknown or deleted user ({inviter})").format(
inviter=data["inviter"]
Expand All @@ -694,7 +699,8 @@ async def get_invite_link(self, member: discord.Member) -> str:
entry = await self.get_audit_log_entry(guild, None, action)
if entry:
possible_link = _("https://discord.gg/{code}\nInvited by: {inviter}").format(
code=entry.target.code, inviter=str(entry.target.inviter)
code=entry.target.code,
inviter=getattr(entry.target.inviter, "mention", _("Unknown")),
)
return possible_link

Expand Down

0 comments on commit 63e8065

Please sign in to comment.