Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AttributeError: 'User' object has no attribute 'joined_at' [discord.py]

I am using this code to get a date when a user joined the server

if answers['member_older'] != None:
      for i in range (len(id)):
        x = id[i]
        account_memb = client.get_user(x)
        print(account_memb)
        joined = account_memb.joined_at
        new_date_memb = datetime.today() - joined
        member_old = new_date_memb.days
        if member_old < answers["member_older"]:
          users.pop(users.index(account_memb))
          print(users)

but for some reason it is showing an attribute error

Task exception was never retrieved
future: <Task finished name='Task-56' coro=<_create.<locals>.start() done, defined at d:\Giveaway Bot\main.py:412> exception=AttributeError("'User' object has no attribute 'joined_at'")>
Traceback (most recent call last):
  File "d:\Giveaway Bot\main.py", line 477, in start
    joined = account_memb.joined_at
AttributeError: 'User' object has no attribute 'joined_at'

I’m using a similar code to get a date when the user’s account was created and it is working perfectly

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    if answers['acc_older'] != None:
      for i in range (len(id)):
        n = id[i]
        account =  client.get_user(n)
        created_at = account.created_at
        new_date = datetime.today() - created_at
        old_days = new_date.days
        if old_days < answers['acc_older']:
          users.pop(users.index(account))
          print(users)

>Solution :

joined_at is an attribute of the Member object, not User object. I think you’ll need to change up your code to get a member instead for this piece of code to work.

discord.py documentation for getting members

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading