dp
disco-py
pypi i disco-py
dp

disco-py

Discord Python library for people that like to dance

by Andrei Zbikowski

0.0.12 (see all)License:MIT
pypi i disco-py
Readme

disco

Disco is a simple and extendable library for the Discord API. Join the Official channel and chat here.

  • 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:

NameReason
requests[security]adds packages for a proper SSL implementation
ujsonfaster json parser, improves performance
erlpack (2.x), earl-etf (3.x)ETF parser run with the --encoder=etf flag
gipcGevent 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):

GitHub Stars

247

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

45

OPEN ISSUES

3

OPEN PRs

2
VersionTagPublished
0.0.14rc1
2yrs ago
0.0.13rc2
4yrs ago
0.0.13rc1
4yrs ago
0.0.12
4yrs ago
No alternatives found
No tutorials found
Add a tutorial