From 459f3214ee1ccef0cc64cc6a5e48c6cc6707f40a Mon Sep 17 00:00:00 2001 From: KnownBlackHat Date: Mon, 1 May 2023 02:20:31 +0530 Subject: [PATCH] fix: ghost logging on remove listener --- Cogs/join_alert.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Cogs/join_alert.py b/Cogs/join_alert.py index 8891c54..c135f2e 100644 --- a/Cogs/join_alert.py +++ b/Cogs/join_alert.py @@ -38,26 +38,27 @@ async def on_guild_join(self, guild): @commands.Cog.listener() async def on_guild_remove(self, guild): - embed = Embeds.emb( - Embeds.red, - guild.name, - f""" - Guild Id: {guild.id} - Owner Id: {guild.owner_id} - Vanity Invite Link: {guild.vanity_url_code} - Members Count: {guild.member_count} - """, - ) - db.config.delete_one({"guild_id": guild.id}) - db.traffic.delete_one({"guild_id": guild.id}) - await send_webhook( - embed=embed, - webhook_url=os.getenv("whtraffic"), - username="Guild Leave Logger", - avatar_url="https://cdn.discordapp.com/avatars/10" - "87375480304451727/f780c7c8c052c66c89f9270aebd63b" - "c2.png?size=1024", - ) + if guild.name: + embed = Embeds.emb( + Embeds.red, + guild.name, + f""" + Guild Id: {guild.id} + Owner Id: {guild.owner_id} + Vanity Invite Link: {guild.vanity_url_code} + Members Count: {guild.member_count} + """, + ) + db.config.delete_one({"guild_id": guild.id}) + db.traffic.delete_one({"guild_id": guild.id}) + await send_webhook( + embed=embed, + webhook_url=os.getenv("whtraffic"), + username="Guild Leave Logger", + avatar_url="https://cdn.discordapp.com/avatars/10" + "87375480304451727/f780c7c8c052c66c89f9270aebd63b" + "c2.png?size=1024", + ) def setup(client: commands.Bot):