From e441b462a4a9f7f942757985f76a326ce9dc323f Mon Sep 17 00:00:00 2001 From: B1ue-Dev <60958064+B1ue-Dev@users.noreply.github.com> Date: Wed, 5 Jul 2023 01:07:46 +0700 Subject: [PATCH] fix: Guild cache can be None --- exts/server/logs.py | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/exts/server/logs.py b/exts/server/logs.py index 77b35f7..b929049 100644 --- a/exts/server/logs.py +++ b/exts/server/logs.py @@ -173,30 +173,27 @@ async def on_guild_member_remove( ) -> None: """GUILD_REMOVE gateway event.""" - if _member.member.guild: - member = _member.member - embed = interactions.Embed( - title="Goodbye! 😢", - description="".join( - [ - f"Goodbye **{member.username}#{member.discriminator}**!", - f" Thanks for joining {member.guild.name}.", - ], - ), - color=random.randint(0, 0xFFFFFF), - timestamp=datetime.datetime.utcnow(), - footer=interactions.EmbedFooter(text=f"ID: {member.id}"), - thumbnail=interactions.EmbedAttachment( - url=member.user.avatar.url if member.user.avatar else None - ), - ) + member = _member.member + guild_name = (self.client.get_guild(_member.guild_id)).name + embed = interactions.Embed( + title="Goodbye! 😢", + description="".join( + [ + f"Goodbye **{member.username}#{member.discriminator}**!", + f" Thanks for joining {guild_name}.", + ], + ), + color=random.randint(0, 0xFFFFFF), + timestamp=datetime.datetime.utcnow(), + footer=interactions.EmbedFooter(text=f"ID: {member.id}"), + thumbnail=interactions.EmbedAttachment( + url=member.user.avatar.url if member.user.avatar else None + ), + ) - for channel in member.guild.channels: - if ( - channel.name == "welcome-goodbye" - and int(channel.type) == 0 - ): - await channel.send(embeds=embed) + for channel in member.guild.channels: + if channel.name == "welcome-goodbye" and int(channel.type) == 0: + await channel.send(embeds=embed) @interactions.listen(interactions.events.BanCreate) async def on_guild_ban_add(