0

i'm a French Discord bot Developer bot I have an error on my background tasks:

@bot.event
async def on_ready():
    print("prêt")


async def ch_pr():
    await bot.wait_until_ready()

    statuses = [
        "0help ou 0?", f"Sur {len(bot.guilds)} serveurs !",
        "Fait en discord.py !", 
        str(len(set(bot.get_all_members))) + "utilisateurs du bot!"
    ]

    while not bot.is_closed():

        status = random.choice(statuses)

        await bot.change_presence(activity=discord.Game(name=status))

        await asyncio.sleep(3)

My error is:

File main.py,line 38 in ch_pr:
str(len(set(bot.get_all_members))) + "utilisateurs du bot!"
TypeError: Name 'method' object is not iterable.

Thanks for help. I'm coding with repl.it

1
  • 2
    Hey, your question is quite specific. Stackoverflow thrives on questions that can solve problems that affect many people. A good first step could be to change your posts title to be more generic and inclusive (it makes your question easier to answer and easier to be found. SO is not a debugging platform but an encyclopedia based around user feedback. Please consider looking at the following link for a better feel as to how to write a good question: stackoverflow.com/help/how-to-ask Commented Jan 3, 2021 at 19:43

1 Answer 1

4

It's a method, not an attribute. You need to actually call the method as well.

bot.get_all_members()

Mind the brackets ().

Also, don't spam-change your status, Discord won't appreciate that & you'll get rate-limited. Try doing it once every minute or so.

Sign up to request clarification or add additional context in comments.

1 Comment

If it worked you should mark my answer as correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.