From 6d0a25cca792bbde122370b7dcad47ead1583179 Mon Sep 17 00:00:00 2001 From: nex Date: Tue, 14 Nov 2023 17:16:11 +0000 Subject: [PATCH] Add HTTPS detection --- cogs/other.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cogs/other.py b/cogs/other.py index b8fc6ea..9ab7956 100644 --- a/cogs/other.py +++ b/cogs/other.py @@ -1969,7 +1969,13 @@ class OtherCog(commands.Cog): embed.set_footer(text="Using server {} ({})".format(host, try_hosts.get(host, "Other"))) msg = await ctx.respond(embed=embed, ephemeral=False) - async with httpx.AsyncClient(base_url=f"http://{host}/api", follow_redirects=True) as client: + async with httpx.AsyncClient(follow_redirects=True) as client: + try: + await client.get(f"https://{host}/api/tags") + client.base_url = f"https://{host}/api" + except httpx.ConnectError as e: + client.base_url = f"http://{host}/api" + try: response = await client.get("/tags") response.raise_for_status()