mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Without setting up the logging module, a god number of error conditions and warnings will never be output by the library. This is a common pitfall to forget and it's not documented good enough the consequences of not setting up the logging module when developing applications with this library.
27 lines
583 B
Python
27 lines
583 B
Python
import discord
|
|
import logging
|
|
|
|
# Set up the logging module to output diagnostic to the console.
|
|
logging.basicConfig()
|
|
|
|
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()
|