B Lab
B Lab

Reputation: 5

How do I make a discord bot print a single message on multiple lines?

I want my bot to send multiple lines without making a new message each time. Below is what it currently outputs. I highlighted the text to show that the 'Uncommon:' is one separate message than the others. https://cdn.discordapp.com/attachments/529146682882129921/849638127785345044/Untitled-1.png

This is what I want it to output, it is multiple lines but all on one message. https://cdn.discordapp.com/attachments/529146682882129921/849638125205848104/Untitled-2.png

I am using python and discord.py to code this. The variables are held in lists, titled horn and onhorn, and the code is taking multiple values from it and generating a random one.

        if message.content.startswith('!gen uncommon'):
            await message.channel.send("Uncommon:")
            await message.channel.send("> Horn: " + random.choice(random.choice(horn[0:2])))
            await message.channel.send("> On horn trait: " + random.choice(random.choice(onhorn[0:2])))

Upvotes: 0

Views: 1127

Answers (1)

Łukasz Kwieciński
Łukasz Kwieciński

Reputation: 15689

Just use the newline character (\n)

if message.content.startswith('!gen uncommon'):
    await message.channel.send(f"Uncommon:\n> Horn: {random.choice(random.choice(horn[0:2]))}\n> On horn trait: {random.choice(random.choice(onhorn[0:2]))}")

Upvotes: 1

Related Questions