You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gsd 98d630d1be ratelimit fix 2 years ago
disco ratelimit fix 2 years ago
docs migrate/deprecate discordapp.com => discord.com (#181) 5 years ago
examples Added listener (pm user on guild join) example (#94) 6 years ago
tests Cleanup support for creating custom plugin base classes (#128) 6 years ago
.biblio.yaml Rework Documentation (#20) 8 years ago
.flake8 Move flake8 reqs to tests require, exclude silly pycodestyle rule 7 years ago
.gitignore Cleanup support for creating custom plugin base classes (#128) 6 years ago
.travis.yml [ci] install flake8 (fixes builds) 6 years ago
CHANGELOG.md Release v0.0.12 7 years ago
MANIFEST.in Add manifest file 9 years ago
README.md migrate/deprecate discordapp.com => discord.com (#181) 5 years ago
requirements.txt dependency version ranges (#183) 4 years ago
setup.cfg Fix travis and pathing 8 years ago
setup.py Added Long Description type (#166) 5 years ago

README.md

disco

PyPI PyPI TravisCI

Disco is an extensive and extendable Python 2.x/3.x library for the Discord API. Disco boasts the following major features:

  • Expressive, functional interface that gets out of the way
  • Built for high-performance and efficiency
  • Configurable and modular, take the bits you need
  • Full support for Python 2.x/3.x
  • Evented networking and IO using Gevent

Installation

Disco was built to run both as a generic-use library, and a standalone bot toolkit. Installing disco is as easy as running pip install disco-py, however some extra packages are recommended for power-users, namely:

Name Reason
requests[security] adds packages for a proper SSL implementation
ujson faster json parser, improves performance
erlpack (2.x), earl-etf (3.x) ETF parser run with the --encoder=etf flag
gipc Gevent IPC, required for autosharding

Examples

Simple bot using the builtin bot authoring tools:

from disco.bot import Bot, Plugin


class SimplePlugin(Plugin):
    # Plugins provide an easy interface for listening to Discord events
    @Plugin.listen('ChannelCreate')
    def on_channel_create(self, event):
        event.channel.send_message('Woah, a new channel huh!')

    # They also provide an easy-to-use command component
    @Plugin.command('ping')
    def on_ping_command(self, event):
        event.msg.reply('Pong!')

    # Which includes command argument parsing
    @Plugin.command('echo', '<content:str...>')
    def on_echo_command(self, event, content):
        event.msg.reply(content)

Using the default bot configuration, we can now run this script like so:

python -m disco.cli --token="MY_DISCORD_TOKEN" --run-bot --plugin simpleplugin

And commands can be triggered by mentioning the bot (configured by the BotConfig.command_require_mention flag):