Skip to content

Commit

Permalink
merge ctx manager to one line
Browse files Browse the repository at this point in the history
  • Loading branch information
Infernum1 committed Apr 4, 2024
1 parent 97f04e3 commit dc60e23
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions bot/cogs/commands/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,23 @@ async def mcstatus(self, ctx: Ctx, host=None, port: int = None):

combined = f"{host}{port_str}"

async with SuppressCtxManager(ctx.typing()):
async with minecraftstatus.MCStatus() as client:
try:
server = await client.get_server(combined.replace("/", "%2F"))
server_card = await client.get_server_card(combined.replace("/", "%2F"))

except minecraftstatus.errors.ServerNotFound:
await ctx.reply(
embed=discord.Embed(
color=self.bot.embed_color,
title=ctx.l.minecraft.mcping.title_offline.format(
self.d.emojis.offline, combined
),
async with SuppressCtxManager(ctx.typing()), minecraftstatus.MCStatus() as client:
try:
server = await client.get_server(combined.replace("/", "%2F"))
server_card = await client.get_server_card(combined.replace("/", "%2F"))

except minecraftstatus.errors.ServerNotFound:
await ctx.reply(
embed=discord.Embed(
color=self.bot.embed_color,
title=ctx.l.minecraft.mcping.title_offline.format(
self.d.emojis.offline, combined
),
mention_author=False,
)
),
mention_author=False,
)

return
return

player_list = server.online_players
if player_list is None:
Expand Down

0 comments on commit dc60e23

Please sign in to comment.