Skip to content

Commit

Permalink
try/except/finally
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-psi committed Nov 30, 2024
1 parent d1829a9 commit 5d79493
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@ async def send_friend_request(
utils: "UtilsCog" = cast(
"UtilsCog", cast("ChuniBot", interaction.client).get_cog("Utils")
)
ctx = utils.chuninet(interaction.user.id)

try:
ctx = utils.chuninet(interaction.user.id)
client = await ctx.__aenter__()

await client.send_friend_request(friend_code)
await ctx.__aexit__(None, None, None)

embed.title = "Success"
embed.description = f"Sent a friend request to {self.profile.name}."
Expand All @@ -117,5 +116,7 @@ async def send_friend_request(
embed.description = f"CHUNITHM-NET error {e.code}: {e.description}"
except commands.BadArgument as e:
embed.description = str(e)
finally:
await ctx.__aexit__(None, None, None)

await interaction.followup.send(embed=embed, ephemeral=True)

0 comments on commit 5d79493

Please sign in to comment.