Skip to content

Commit

Permalink
Update on_infraction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Nov 17, 2024
1 parent bf7a3ab commit 63cc3d5
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions Cogs/Events/on_infraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ async def on_infraction(self, objectid: ObjectId, Settings: dict, Actions: dict)
)
return
try:
channel = await guild.fetch_channel(int(ChannelID))
channel = await guild.fetch_channel(int(ChannelID))
except Exception as e:
return print(f'[🏠 on_infraction] @{guild.name} the infraction channel can\'t be found. [1]')
return print(
f"[🏠 on_infraction] @{guild.name} the infraction channel can't be found. [1]"
)
if channel is None:
logging.warning(
f"[🏠 on_infraction] @{guild.name} the infraction channel can't be found. [2]"
Expand Down Expand Up @@ -211,25 +213,42 @@ async def on_infraction(self, objectid: ObjectId, Settings: dict, Actions: dict)
if validator:
if custom.author_icon is not None and custom.author_icon != "":
if ym:
embed.set_author(
name=custom.author if custom.author else "",
icon_url=(
custom.author_icon.url
if custom.author_icon
else None
),
)
try:
embed.set_author(
name=custom.author if custom.author else "",
icon_url=(
custom.author_icon.url
if custom.author_icon
else None
),
)
except:
embed.set_author(
name=custom.author if custom.author else "",
)
else:
embed.set_author(
name=custom.author if custom.author else "",
icon_url=(
custom.author_icon if custom.author_icon else None
),
)
try:
embed.set_author(
name=custom.author if custom.author else "",
icon_url=(
custom.author_icon
if custom.author_icon
else None
),
)
except:
embed.set_author(
name=custom.author if custom.author else "",
)
else:
if custom.author and not custom.author_icon:
try:
if custom.author and not custom.author_icon:
embed.set_author(
name=custom.author if custom.author else ""
)
except:
embed.set_author(
name=custom.author if custom.author else ""
name=custom.author if custom.author else "",
)

embed.set_thumbnail(url=custom.thumbnail if custom.thumbnail else None)
Expand All @@ -256,7 +275,12 @@ async def on_infraction(self, objectid: ObjectId, Settings: dict, Actions: dict)
if ch and isinstance(ch, discord.TextChannel):
channel = ch
try:
msg = await channel.send(staff.mention, embed=embed, view=view, allowed_mentions=discord.AllowedMentions(users=True))
msg = await channel.send(
staff.mention,
embed=embed,
view=view,
allowed_mentions=discord.AllowedMentions(users=True),
)
except (discord.Forbidden, discord.HTTPException, discord.NotFound):
return
await infractions.update_one(
Expand Down

0 comments on commit 63cc3d5

Please sign in to comment.