From 63e806599965e3bcecbc13da956c32c7c90763ca Mon Sep 17 00:00:00 2001 From: TrustyJAID Date: Fri, 30 Aug 2024 15:56:41 -0600 Subject: [PATCH] [ExtendedModLog] Try and mention inviters if possible --- extendedmodlog/eventmixin.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/extendedmodlog/eventmixin.py b/extendedmodlog/eventmixin.py index 34f9ed50c3..cfcba10c81 100644 --- a/extendedmodlog/eventmixin.py +++ b/extendedmodlog/eventmixin.py @@ -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: @@ -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"] @@ -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