Fixed error when no channel is specified

This commit is contained in:
Simon 2018-12-01 11:30:29 -05:00
parent 5a6e36daf4
commit 2074ee8d92

View File

@ -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: