A Python library for Discord
Project description
disca
Disco is an extensive and extendable Python 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 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 disca is as easy as running pip install disca-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 disca.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 disca.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):
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file disca-0.0.14.tar.gz
.
File metadata
- Download URL: disca-0.0.14.tar.gz
- Upload date:
- Size: 68.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d30187fcefdf82d7e59f75b790b6e93d7d5c21ab5a3ccf99a022c889bc72d93 |
|
MD5 | c86b53e43277412cf01cb58d43f93903 |
|
BLAKE2b-256 | ef137029951b8461e6fa30e44f1c0a9fc17e0794ccba9dc962453c3dcef2f28a |
File details
Details for the file disca-0.0.14-py3-none-any.whl
.
File metadata
- Download URL: disca-0.0.14-py3-none-any.whl
- Upload date:
- Size: 82.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bb24fd67d1fe36f9470a0eda5f31f38d6cf5b6f8f7379ad4ee7f44fe23272df |
|
MD5 | 7e92469cd7506a929e3193c458a366f3 |
|
BLAKE2b-256 | dec401084af485829eddbd5da9aa5009098fd43f3f4aaeb6690e51641514f437 |