W
W
wz2021-07-05 16:08:52
Python
wz, 2021-07-05 16:08:52

AttributeError: 'Bot' object has no attribute 'members'?

I am making an economic bot on D.py, I wrote an event and tried to start the bot but gave an error

spoiler
AttributeError: 'Bot' object has no attribute 'members'

I googled all over and didn't find anything.

The code:
@bot.event
async def on_ready():
    await bot.change_presence(status=discord.Status.online, activity=discord.Streaming(name="!help > discord.gg/-----", url="url"))
    cur.execute("""CREATE TABLE IF NOT EXISTS users (
            name TEXT,
            id INT,
            cash BIGINT,
            rep INT,
            hp INT,
            lvl INT
        )""")
    connection.commit()

    for guild in bot.guilds:
        for member in bot.members:
            if cur.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
                cur.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 25, 0)")
            else:
                pass
    
    connection.commit()

    print(f"Succesfully logined as {bot.name}")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dream, 2021-07-05
@rensly

for member in guild.members:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question