question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'NoneType' object has no attribute 'id'

See original GitHub issue

I’ve seen this issue posted here multiple times and it is usually said to be an issue of the code but there is one from 10 days ago that seemed to not have an answer yet, so I’m thinking there still may be an issue in the code here?

Doing:

mgs = []
async for x in client.logs_from(client.get_channel('361683030932193281')):
    mgs.append(x)
await client.delete_messages(mgs)

Getting “‘NoneType’ object has no attribute ‘id’”…

Tried doing it a multitude of different ways including having the get_channel code as it’s own line with a name and whatnot.

Traceback: https://i.imgur.com/z4ptQt3.png

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
Gorialiscommented, Oct 7, 2017

get_channel returns None when a channel with the specified channel ID was not found in the cache. This raises some possibilities:

  • The channel is not in cache yet. Try using wait_until_ready, which sleeps the coroutine until all channels, guilds and members are available in cache.
  • This channel doesn’t exist (you copied the ID wrong or similar)
  • The bot logged in can’t actually see the channel (this doesn’t mean that it can’t read from it and should only happen when not in a mutual guild)

Judging by your last comment, I’m going to guess it’s the first one. Stick a

await client.wait_until_ready()

before your main code and see if it fixes the problem.

2reactions
dskjfhsdfjhcommented, Oct 27, 2020

That fixed it. (wait_until_ready(), not the rest) Thanks, Gorialis. Great answer.

could u explain how to add this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nonetype object has no attribute 'id' - python - Stack Overflow
This occurs when the you try to get id Attribute from object which is of None type , Here is a case :...
Read more >
'NoneType' object has no attribute 'id' - asdeasoft.net
Re: 'NoneType' object has no attribute 'id' ... AttributeError means that there was an Error that had to do with an Attribute request....
Read more >
Getting 'NoneType' object has no attribute 'id' error - Reddit
Can you help me solve this issue described on the post title? I am getting this error with this specific code: latest =…...
Read more >
AttributeError: 'NoneType' object has no attribute 'id' - Trac
Hey guys,. I receive an error using the latest stable version (0.12.2) that I did not find back in already existing bug reports....
Read more >
'NoneType' object has no attribute 'user_id' - Odoo
Website admin config has an "AttributeError: 'NoneType' object has no attribute 'user_id'" ... Thanks for your subscription! Does anyone know how to correct...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found