From dc60e23cb6a7f5fec506a67b38e7d6f559a24f54 Mon Sep 17 00:00:00 2001 From: Infernum11 <81740112+Infernum1@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:54:05 +0530 Subject: [PATCH] merge ctx manager to one line --- bot/cogs/commands/minecraft.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/bot/cogs/commands/minecraft.py b/bot/cogs/commands/minecraft.py index d86e9f2e..2c7fa43e 100644 --- a/bot/cogs/commands/minecraft.py +++ b/bot/cogs/commands/minecraft.py @@ -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: