|NOTE:||This is a fork of discord.py that is kept automatically up-to-date with the upstream/rewrite branch of discord.py. There are slight modifications which do not change any major core compatibility. Several
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.
- Modern Pythonic API using
- Proper rate limit handling.
- 100% coverage of the supported Discord API.
- Optimised in both speed and memory.
To install the development (rewrite) version, do the following:
# Linux/macOS python3 -m pip install -U https://github.com/gieseladev/discord.py/archive/rewrite.zip#egg=discord.py[voice] # Windows py -3 -m pip install -U https://github.com/gieseladev/discord.py/archive/rewrite.zip#egg=discord.py[voice]
- PyNaCl (for voice support)
Please note that on Linux installing voice you must install the following packages via your favourite package manager (e.g.
yum, etc) before running the above commands:
- libffi-dev (or
libffi-develon some systems)
- python-dev (e.g.
python3.6-devfor Python 3.6)
import discord class MyClient(discord.Client): async def on_ready(self): print('Logged on as', self.user) async def on_message(self, message): # don't respond to ourselves if message.author == self.user: return if message.content == 'ping': await message.channel.send('pong') client = MyClient() client.run('token')
import discord from discord.ext import commands bot = commands.Bot(command_prefix='>') @bot.command() async def ping(ctx): await ctx.send('pong') bot.run('token')
You can find more examples in the examples directory.