I am printing out a lot of values using ljust like this:
for cog in bot.cogs:
cogobj = bot.get_cog(cog)
try:
print('+' + '-' * 105 + '+')
print('| ' + cogobj.qualified_name.upper())
if cogobj.description:
print('| ' + cogobj.description)
print('+' + '-' * 105 + '+')
except AttributeError:
pass
for c in cogobj.get_commands():
print(f"• {c.name} {c.signature.replace('_', '')}".ljust(35, ' ') + f' {c.help}')
if isinstance(c, commands.Group):
for sc in c.commands:
print(''.ljust(5, ' ') + f"▪ {sc.name} {sc.signature.replace('_', '')}".ljust(35, ' ') + f' {sc.help}')
print('\n')
This will print out something like this
+---------------------------------------------------------------------------------------------------------+
| FUN
| Category with fun commands
+---------------------------------------------------------------------------------------------------------+
• embed <title> <description> Will send an embed with <title> and <description>, who's colour will change every 10 seconds
• channel Base command for creating or removing a lot of channels in a guild
▪ create <amount> <type> [name] Will create <amount> of text or voice channels in guild
▪ remove <amount> Will remove <amount> of text and voice channels in a guild
But the problem is that sometimes when the c.help or cs.help is long, or when I use a \n character, it will jump into a new line making it look like this:
• eval <body> Will evaluate python code and discord.py code.
This means you can basically run any script anywhere anytime.
...
When I would like it to look like
• eval <body> Will evaluate python code and discord.py code.
This means you can basically run any script anywhere anytime.
I have tried this with tabulate, but that creates a weird matrix looking table.
So I guess my question is, is there a way to set a max length of a string that automatically joins into a new line with the same ljust?