I want my bot to be able to say a message, mention a user, then respond with a random message, all in the same line, as opposed to having it in 3 separate lines.
This was my previous method:
if msg.startswith('respond') await message.channel.send('alright then,') await message.channel.send(message.author.mention) await message.channel.send(random.choice(responses))
However, this makes them all appear in the same line, but I can’t figure out how to merge them into a singular line. This was one of my many failed attempts:
if msg.startswith('respond'): await message.channel.send ('alright then, <message.author.mention> <random.choice(responses)>')
(please don’t make fun of my amateur coding skills lmao)
Advertisement
Answer
assuming you are using python3+, you could do f-strings
if msg.startswith('respond'): await message.channel.send(f'alright then, {message.author.mention} {random.choice(responses)}')
there are other alternatives to this, such as format strings
if msg.startswith('respond'): await message.channel.send('alright then, {} {}'.format(message.author.mention, random.choice(responses))
concatenation methods like
if msg.startswith('respond'): await message.channel.send('alright then, ' + message.author.mention + ' ' + random.choice(responses))