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:
parent
68c3fde089
commit
a98324fbf8
@ -3,6 +3,10 @@ import discord
|
|||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
client.login('email', 'password')
|
client.login('email', 'password')
|
||||||
|
|
||||||
|
if not client.is_logged_in:
|
||||||
|
print('Logging in to Discord failed')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
def on_ready():
|
def on_ready():
|
||||||
print('Connected!')
|
print('Connected!')
|
||||||
|
@ -3,6 +3,10 @@ import discord
|
|||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
client.login('email', 'password')
|
client.login('email', 'password')
|
||||||
|
|
||||||
|
if not client.is_logged_in:
|
||||||
|
print('Logging in to Discord failed')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
def on_ready():
|
def on_ready():
|
||||||
print('Connected!')
|
print('Connected!')
|
||||||
|
@ -4,6 +4,10 @@ import time
|
|||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
client.login('email', 'password')
|
client.login('email', 'password')
|
||||||
|
|
||||||
|
if not client.is_logged_in:
|
||||||
|
print('Logging in to Discord failed')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
def on_ready():
|
def on_ready():
|
||||||
print('Connected!')
|
print('Connected!')
|
||||||
|
@ -3,6 +3,10 @@ import discord
|
|||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
client.login('email', 'password')
|
client.login('email', 'password')
|
||||||
|
|
||||||
|
if not client.is_logged_in:
|
||||||
|
print('Logging in to Discord failed')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
def on_message(message):
|
def on_message(message):
|
||||||
if message.content.startswith('!hello'):
|
if message.content.startswith('!hello'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user