discord.py/examples/reply.py
Hornwitser a98324fbf8 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.
2015-10-06 19:09:16 +02:00

23 lines
480 B
Python

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'):
client.send_message(message.channel, 'Hello {}!'.format(message.author.mention()))
@client.event
def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run()