Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 99665db

Browse files
authored
Update bot.py
1 parent 851d064 commit 99665db

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

bot.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ async def Login(ctx, *, nick):
463463
"""Should help you in error cases"""
464464
server = ctx.channel.name
465465
if nick.lower() == MY_NICKS[server].lower():
466-
session = sessions[server]
467466
sessions[server] = login.login(server)
468467

469468
@bot.command()
@@ -483,22 +482,24 @@ async def on_message(message):
483482
await bot.invoke(ctx)
484483
output = f.getvalue()
485484

486-
if "notLoggedIn" in output:
485+
if "notLoggedIn" in output or "error" in output:
486+
ctx = await bot.get_context(message)
487487
f = StringIO()
488-
login.login(ctx.channel.name)
488+
sessions[ctx.channel.name] = login.login(ctx.channel.name)
489489
with redirect_stdout(f):
490490
await bot.invoke(ctx)
491491
output = f.getvalue()
492492

493-
if len(output) > 100 or "http" in output:
494-
embed = discord.Embed()
495-
embed.add_field(name=os.environ['nick'], value=output[:1000])
496-
if output[1000:]:
497-
embed.add_field(name="Page 2", value=output[1000:2000])
498-
# Sending the output (all prints) to your channel.
499-
await ctx.send(embed=embed)
500-
else:
501-
await ctx.send(output[:2000])
493+
if output:
494+
if len(output) > 100 or "http" in output:
495+
embed = discord.Embed()
496+
embed.add_field(name=os.environ['nick'], value=output[:1000])
497+
if output[1000:]:
498+
embed.add_field(name="Page 2", value=output[1000:2000])
499+
# Sending the output (all prints) to your channel.
500+
await ctx.send(embed=embed)
501+
else:
502+
await ctx.send(output[:2000])
502503
f.close()
503504

504505
@bot.event

0 commit comments

Comments
 (0)