Skip to main content

Python framework for Discord interactions using a web server

Project description

disunity

Python framework for Discord interactions using a web server

Installation

pip install disunity

Introduction to Disunity

import disunity

server = disunity.DisunityServer()

if __name__ == '__main__':
    server.run()

Using packages

import disunity
import pathlib

server = disunity.DisunityServer()

@server.before_serving
def load_packages():
    for package in [f"{f.parent}.{f.stem}" for f in pathlib.Path("packages").glob("*.py")]:
        server.load_package(package)

if __name__ == '__main__':
    server.run()

Setting up a package

from disunity import package, utils

class FirstPackage(package.Package):
    def __init__(self, app):
        self.app = app

    @package.Package.command('ping')
    async def ping(self, ctx):
        return await ctx.callback("Pong!")

def setup(app):
    app.register_package(FirstPackage(app))

Disclaimer

This will require that you already have hosting service for the server to run on as well as a domain to host the server on. If you have neither of these, an alternative would be to host on Heroku using a web application with Gunicorn.

Side note

The server will receive interactions to the /interactions endpoint of your server. It will look like this: https://example.com/interactions. Once you run the server, put the url with the added interactions endpoint into the interactions URL on your app located in the Discord developer portal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disunity-0.1.17.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

disunity-0.1.17-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file disunity-0.1.17.tar.gz.

File metadata

  • Download URL: disunity-0.1.17.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for disunity-0.1.17.tar.gz
Algorithm Hash digest
SHA256 c58619404851e572d81769e55d620a067a647e4836adec5401c5b4e00caa8dc3
MD5 ecf24d33bceba41977b016b78f95134f
BLAKE2b-256 af2c4c91034428e6efcf64bf86eeed1b75b586ae9a30074e63ff15ff69a86a9e

See more details on using hashes here.

File details

Details for the file disunity-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: disunity-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for disunity-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 edb1798d5afe6c0caaca1b40667918be4344d76b15072d3a11600b9121370468
MD5 34fd10be354387a86c9fd7a031020053
BLAKE2b-256 492b6fefdecf591919db94820a5f77e1aa7e6727493e9b3dc1ae9032144207ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page