mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-31 05:23:03 +00:00 
			
		
		
		
	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:
		| @@ -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!') | ||||
|   | ||||
| @@ -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!') | ||||
|   | ||||
| @@ -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!') | ||||
|   | ||||
| @@ -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'): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user