Add handling of login failure in examples

Check and handle login failure in the examples provided for using this
library.  This is a common error condition that should be handled by any
script using this library.
This commit is contained in:
Hornwitser 2015-09-30 19:58:19 +02:00
parent 68c3fde089
commit a98324fbf8
4 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,10 @@ import discord
client = discord.Client()
client.login('email', 'password')
if not client.is_logged_in:
print('Logging in to Discord failed')
exit(1)
@client.event
def on_ready():
print('Connected!')

View File

@ -3,6 +3,10 @@ import discord
client = discord.Client()
client.login('email', 'password')
if not client.is_logged_in:
print('Logging in to Discord failed')
exit(1)
@client.event
def on_ready():
print('Connected!')

View File

@ -4,6 +4,10 @@ import time
client = discord.Client()
client.login('email', 'password')
if not client.is_logged_in:
print('Logging in to Discord failed')
exit(1)
@client.event
def on_ready():
print('Connected!')

View File

@ -3,6 +3,10 @@ import discord
client = discord.Client()
client.login('email', 'password')
if not client.is_logged_in:
print('Logging in to Discord failed')
exit(1)
@client.event
def on_message(message):
if message.content.startswith('!hello'):