mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 04:17:16 +00:00
Apparently the clever hack for logging in on_error was not so clever after all. If logging isn't configured, by the logging modules definition of not configured, which is root logger not having an Handlers attached, it will call logging.basicConfig(). Which messes up setups that define handlers for other loggers than the root logger. Going directly to the root logger rather than using the broken convenience methods for logger is not an option either, as logger before Python 3.2 does not have lastResort on the root logger, and prints an error when invoked without any handlers. Resolve by printing tracebacks to stderr by default in on_error.
discord.py
discord.py is an API wrapper for Discord written in Python.
This was written to allow easier writing of bots or chat logs.
Installing
Installing is pretty easy.
pip install discord.py
Will install the latest 'stable' version of the library.
If you want to install the development version of the library, then do the following:
pip install git+https://github.com/Rapptz/discord.py@develop
This module is alpha!
The discord API is constantly changing and the wrapper API is as well. There will be no effort to keep backwards compatibility.
I recommend that you follow the discussion in the unofficial Discord API discord channel and update your installation periodically through pip install --upgrade discord.py
.
Quick Example
import discord
client = discord.Client()
client.login('email', 'password')
@client.event
def on_message(message):
if message.content.startswith('!hello'):
client.send_message(message.channel, 'Hello was received!')
@client.event
def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run()
You can find examples in the examples directory.
Requirements
- Python 2.7+ or Python 3.3+.
ws4py
libraryrequests
library
Usually pip
will handle these for you.
Related Projects
Languages
Python
100%