How to make bot reply in a single message?

Viewed 171

I want to make my bot respond in a single message, but because of the for loop it replies 10 times in 10 different messages. My code is:

@bot.command(name='translate', help='- Translates text to a random language!')
async def translating(ctx, thing):
    translator = Translator()
    for i in range(0, 10):
        translation = translator.translate(thing, dest=str(random.choice(list_language_unicodes)))
        await ctx.reply(translation.text)

The code takes a string and translates it to 10 random different languages if somebody was interested. My problem is only with the bot NOT replying in a SINGLE message. I'm a beginner so i probably won't understand much but still.

1 Answers

Solution: I concatenated the strings and reset at the end of the loop because the translations kept stacking:

for i in range(0, 10):
        translation = translator.translate(thing, dest=str(random.choice(list_language_unicodes)))
        finalny_tekst = finalny_tekst + translation.text + "\n"
    await ctx.reply(finalny_tekst)
    finalny_tekst = ""

Thanks for assistance!

Related