ArvinJA / scrape_discord

Scrape discord channels
27 stars 7 forks source link

TypeError: 'LogsFromIterator' object is not iterable #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

hi, i'm getting this error when trying to scrape a channel

# python scrape_channels.py --server_id X --user X --password X --token X --channels X
Logged in as
bamtan
------
scraping logs for general
Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "scrape_channels.py", line 35, in on_ready
    yield from scrape_logs_from(channel)
  File "scrape_channels.py", line 69, in scrape_logs_from
    gen = yield from client.logs_from(channel, limit=1)
TypeError: 'LogsFromIterator' object is not iterable
ghost commented 6 years ago

I believe I managed to get past this first error after switching over to my Debian distro, but now I am getting the following:

Traceback (most recent call last):
  File "/home/tower/.local/lib/python3.5/site-packages/discord/client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "scrape_channels.py", line 33, in on_ready
    for channel in sorted(channels, key=lambda c: c.position):
  File "scrape_channels.py", line 33, in <lambda>
    for channel in sorted(channels, key=lambda c: c.position):
AttributeError: 'NoneType' object has no attribute 'position'
ArvinJA commented 6 years ago

@bamtan Weird. I've now now added a step where non-existing channels are filtered out, but I'm wondering how you managed to get non-existing channels in the first place. You're aware that you have to use channel id's right (excuse me if this is obvious)?

If you want to, I could join the discord server and try to replicate your problem exactly, if it still persists after the update.

Not sure what the problem for the first issue might have been.

ghost commented 6 years ago

Still getting the following error:

debian:~/scrape_discord$ python3 scrape_channels.py --server_id X --user X@gmail.com --password X --token X --channels X
Logged in as
bamtan
------
scraping logs for general
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/tower/.local/lib/python3.5/site-packages/discord/client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "scrape_channels.py", line 40, in on_ready
    yield from scrape_logs_from(channel)
  File "scrape_channels.py", line 74, in scrape_logs_from
    gen = yield from client.logs_from(channel, limit=1)
TypeError: 'LogsFromIterator' object is not iterable

I'm using the proper channel ID as you can see above. It also creates the directory and text files, though nothing written into it.

ArvinJA commented 6 years ago

@bamtan Alright. I've done some refactoring, I don't know if this fixes the issue. If you're using a regular user instead of a bot user to scrape, add --selfbot for this release (although selfbots break ToS and shouldn't really be used, afaict). Since I can't replicate your issue, it'd still be good if I can get an invite to the server you're trying to scrape.

zeratax commented 6 years ago

I am fairly sure the problem here is .local/lib/python3.5 I encountered the same problem and apparently the asyncio syntax changed between python3.4 and python3.5. So either you adjust the code to the new syntax or run this code with python3.4

See: https://docs.python.org/3/whatsnew/3.5.html#whatsnew-pep-492

ArvinJA commented 6 years ago

@ZerataX Thanks, yup, seems like I had to make it compatible with newer python versions. Tested with python 3.6.4, and it works, hopefully it'll work for python 3.5 as well :)

@bamtan try the new version