D
D
Denis2021-11-22 22:26:06
Python
Denis, 2021-11-22 22:26:06

Error AttributeError: 'int' object has no attribute 'id' how to fix?

Hello, the error occurs AttributeError: 'int' object has no attribute 'id'
Here is the code:

@tasks.loop(seconds=2.0)
async def ban_loop():
  getdatanow = datetime.now().date()
  for ban in sql.execute(F"SELECT days FROM bans"):
    ban1 = datetime.strptime(ban[0], "%Y-%m-%d").date()
    if getdatanow >= ban1:
      sql.execute(f"UPDATE bans SET ex = 1")
      db.commit()
      print(getdatanow >= ban1)
      for bans in sql.execute(f"SELECT banned FROM bans WHERE ex = 1"):
        guild = client.get_guild(806633419865718784)
        await guild.unban(bans[0])
        print('Пользователь разбанен по истечению длительности наказания')


Please help.
The error occurs in the for bans loop

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-11-22
@nosemka

guild.unban() expects an object of the User class as an argument, not a number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question