mirror of
https://github.com/simon987/Discord-Channel-scraper.git
synced 2025-04-20 02:16:41 +00:00
Fixed error when no channel is specified
This commit is contained in:
parent
5a6e36daf4
commit
2074ee8d92
@ -27,7 +27,7 @@ parser.add_argument('--flag', '-f', action='store', default="!yank", help='An al
|
|||||||
' Default value is "!yank", activates by'
|
' Default value is "!yank", activates by'
|
||||||
' default if no server is specified.')
|
' default if no server is specified.')
|
||||||
parser.add_argument('--quiet', '-q', action='store_true', help='Suppress messages in Discord')
|
parser.add_argument('--quiet', '-q', action='store_true', help='Suppress messages in Discord')
|
||||||
parser.add_argument('--server', '--guild','-s', action='store', help='Discord server name to scrape from '
|
parser.add_argument('--server', '--guild', '-s', action='store', help='Discord server name to scrape from '
|
||||||
'(user must be a member of the server and'
|
'(user must be a member of the server and'
|
||||||
' have history privileges). This field is case'
|
' have history privileges). This field is case'
|
||||||
' sensitive. If channel is not specified the '
|
' sensitive. If channel is not specified the '
|
||||||
@ -77,8 +77,8 @@ async def get_logs(channel):
|
|||||||
log.info("Messages for channel {0} finished downloading".format(channel.name))
|
log.info("Messages for channel {0} finished downloading".format(channel.name))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
await client.send_message(channel, 'Failed saving logs: {}'.format(e.message))
|
await client.send_message(channel, 'Failed saving logs: {}'.format(str(e)))
|
||||||
log.error("Error while downloading channel {0}: {1}".format(channel.name, e.message))
|
log.error("Error while downloading channel {0}: {1}".format(channel.name, str(e)))
|
||||||
|
|
||||||
|
|
||||||
# Strangely, this will work once we are logged in
|
# Strangely, this will work once we are logged in
|
||||||
@ -114,7 +114,8 @@ async def on_ready():
|
|||||||
await client.logout()
|
await client.logout()
|
||||||
elif args.server:
|
elif args.server:
|
||||||
log.info("Downloading messages for all channels in server {0}".format(args.server))
|
log.info("Downloading messages for all channels in server {0}".format(args.server))
|
||||||
for channel in server.channels:
|
channels = [c for c in client.get_all_channels() if c.server.name == args.server]
|
||||||
|
for channel in channels:
|
||||||
await get_logs(channel)
|
await get_logs(channel)
|
||||||
await client.logout()
|
await client.logout()
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user