• Stars
    star
    14,368
  • Rank 2,076 (Top 0.05 %)
  • Language
    Python
  • License
    MIT License
  • Created about 9 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An API wrapper for Discord written in Python.

discord.py

Discord server invite PyPI version info PyPI supported Python versions

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

Key Features

  • Modern Pythonic API using async and await.
  • Proper rate limit handling.
  • Optimised in both speed and memory.

Installing

Python 3.8 or higher is required

To install the library without full voice support, you can just run the following command:

# Linux/macOS
python3 -m pip install -U discord.py

# Windows
py -3 -m pip install -U discord.py

Otherwise to get voice support you should run the following command:

# Linux/macOS
python3 -m pip install -U "discord.py[voice]"

# Windows
py -3 -m pip install -U discord.py[voice]

To install the development version, do the following:

$ git clone https://github.com/Rapptz/discord.py
$ cd discord.py
$ python3 -m pip install -U .[voice]

Optional Packages

Please note that when installing voice support on Linux, you must install the following packages via your favourite package manager (e.g. apt, dnf, etc) before running the above commands:

  • libffi-dev (or libffi-devel on some systems)
  • python-dev (e.g. python3.8-dev for Python 3.8)

Quick Example

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')

intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run('token')

Bot Example

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('token')

You can find more examples in the examples directory.

Links

More Repositories

1

RoboDanny

A discord bot for servers that I like.
Python
797
star
2

discord-ext-menus

Python
232
star
3

sol

A C++11 Lua wrapper
C++
205
star
4

asqlite

A simple async wrapper for sqlite3
Python
112
star
5

cpp-sublime-snippet

C++11 Sublime Text Snippets
JavaScript
92
star
6

eos

A simple and easy to use datetime library for Rust
Rust
51
star
7

jimaku

A site for hosting (Japanese) subtitles
Rust
38
star
8

discord-event-bot

Python
34
star
9

discord-ext-native-voice

Rust
33
star
10

Reddit-Imgur-Scraper

Python script that scraps images from imgur on reddit.
Python
30
star
11

DoxyDoc

A sublime text plugin for C++ document autocompletion
Python
27
star
12

power-tabs

Vertical tab groups for Firefox
JavaScript
25
star
13

Gears

C++ Utilities
C++
25
star
14

jsonpp

C++11 JSON parser and writer
C++
21
star
15

aoc2021

Solutions for Advent of Code 2021
Rust
15
star
16

open-collective-discord-auth

The server component for Open Collective Linked Role integration
TypeScript
15
star
17

gum

Thin C++11 SDL 2 wrapper with other nice things.
C++
15
star
18

google-lens-ocr

A simple CLI to invoke Google Lens OCR
Rust
6
star
19

Sky

SFML tools to aid in game development.
C++
5
star
20

sqlitexx

A C++14 SQLite3 wrapper
C++
4
star
21

Lia

List comprehensions for C++
C++
3
star
22

hacktober-cheese

Cheese
3
star
23

Shinobi

A meta build system for ninja
C++
2
star
24

git-utils

Scripts that I use for custom git commands.
Shell
1
star
25

compo-two

2nd Great Lounge Game Jam.
Lua
1
star
26

rapptz.github.io

Github page for my projects.
CSS
1
star
27

sen.py

A pseudo meta build system for ninja.
Python
1
star
28

splatoon

Splatoon data related nonsense.
1
star
29

Project-Euler

Project Euler solutions
C++
1
star
30

anitomy-rs

A pure Rust port of anitomy, an anime filename parser
Rust
1
star
31

libnet

A C++11 library for networking.
C++
1
star