Z
Z
Zac Rider2020-08-10 16:04:47
Python
Zac Rider, 2020-08-10 16:04:47

Does the bot output only the first line of the file?

I can't understand why the bot outputs only the first line of the file, and ignores the subsequent ones

. bruh function:

def bruh():
    for i in f:
        print(i)


Document text:

workspace
true
utils

Code:

@bot.command()
async def s(ctx):
    f = open('kittenB00ks.txt', 'r')
    await ctx.send(embed=discord.Embed(description=f'{bruh()}', color=discord.Color.darker_grey()))
    f.close()


Of course, one could say that you need to replace return with print, but the fact is that because of this, the bot outputs the result to the console, and not to the discord.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-08-10
@b00tyCha1n

Maybe learn the basics first, and then write bots? print is the output to the console by default, return is the exit from the function.
PS for example return f.read(), otherwise it's really trouble, trouble.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question