Skip to content

Commit

Permalink
do not break table
Browse files Browse the repository at this point in the history
  • Loading branch information
Fogapod committed Feb 29, 2024
1 parent 5c9c5b2 commit 4583945
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/cogs/unitystation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ async def servers(self, ctx: Context, *, server: Optional[str] = None) -> None:
await self._server_list.fetch(ctx)

if server is None:
text = await self._servers()
text = await self._servers(ctx)
else:
text = await self._server(server)

await ctx.send(text)
if text is not None:
await ctx.send(text)

async def _server(self, server_name: str) -> str:
server_name = server_name.lower()
Expand Down Expand Up @@ -79,7 +80,7 @@ async def _server(self, server_name: str) -> str:

return f"```\n{main_info}\n\nDownloads\n{downloads}```"

async def _servers(self) -> str:
async def _servers(self, ctx: Context) -> Optional[str]:
servers = self._server_list.servers

if not servers:
Expand All @@ -105,6 +106,19 @@ async def _servers(self) -> str:
row.append(value)
data.append(row)

# this section applies accents to data to not break table alignment
# accents only work in guilds
if ctx.guild is None or (accent_cog := ctx.bot.get_cog("Accents")) is None:

def apply_accent(s: str) -> str:
return s
else:

def apply_accent(s: str) -> str:
return accent_cog.apply_member_accents_to_text(member=ctx.me, text=s) # type: ignore[attr-defined]

data = [[apply_accent(s) for s in row] for row in data]

column_widths: dict[int, int] = {}

for row in data:
Expand All @@ -125,7 +139,9 @@ async def _servers(self) -> str:

body += f"{' | '.join(values)}\n"

return f"```\n{header}\n{separator}\n{body}```"
await ctx.send(f"```\n{header}\n{separator}\n{body}```", accents=[])

return None

@commands.command(aliases=["cl"])
async def changelog(self, ctx: Context, *, build: Optional[str] = None) -> None:
Expand Down

0 comments on commit 4583945

Please sign in to comment.