I’m working on a Discord bot using Python and having trouble getting the output to display the way I want it to look. I need help with formatting the queue display command.
What I want to achieve: I need to add numbered indexes at the beginning of each line, put some indentation before usernames, and create blank lines between each queue entry for better readability.
Here’s my current code:
@client.command(name='list', aliases=['display'], help='Display current waiting list')
async def show_list(ctx):
waiting_list = fetch_server_list(ctx)
current_time = datetime.now()
msg_embed = discord.Embed(title='Waiting List', colour = discord.Colour.green())
if len(waiting_list) == 0:
content='No users waiting!'
else:
items = []
for item in waiting_list:
added_time = datetime.strptime(item['timestamp'], '%Y-%m-%d %H:%M:%S')
minutes_waiting = (current_time-added_time).seconds / 60
if item['note']:
items.append('**{}** *({:.0f} min)*: {}'
.format(item['username'], minutes_waiting, item['note']))
else:
items.append('**{}** *({:.0f} min)*'
.format(item['username'], minutes_waiting))
content='\n'.join(items)
field_name = 'People waiting ({})'.format(len(waiting_list))
msg_embed.add_field(name=field_name, value=content, inline=False)
await ctx.send(embed=msg_embed)
Right now everything runs together without proper spacing or numbering. How can I modify this to get the formatting I’m looking for?