Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Aug 1, 2021. It is now read-only.
/discoPublic archive

Discord Python library for people that like to dance

NotificationsYou must be signed in to change notification settings

b1naryth1ef/disco

Repository files navigation

PyPIPyPITravisCI

Disco is an extensive and extendable Python 2.x/3.x library for theDiscord 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 runningpip 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:

fromdisco.botimportBot,PluginclassSimplePlugin(Plugin):# Plugins provide an easy interface for listening to Discord events@Plugin.listen('ChannelCreate')defon_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')defon_ping_command(self,event):event.msg.reply('Pong!')# Which includes command argument parsing@Plugin.command('echo','<content:str...>')defon_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):


[8]ページ先頭

©2009-2025 Movatter.jp