Skip to content

Commit

Permalink
fix: Guild cache can be None
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ue-Dev committed Jul 4, 2023
1 parent 1d45c63 commit e441b46
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions exts/server/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit e441b46

Please sign in to comment.