GithubHelp home page GithubHelp logo

discord_app's Introduction

Discord Interaction Application framework for Python

Tests Pypi

In early development.

The specification and documentation may change without notification.

Any new ideas are welcomed.

A Flask based Discord Application framework.

System Requirements

Install from PyPI

Install and update using pip:

 $ pip install discord-app

Known Limitation

  • After command specification updated (including new command), Discord clients may require up to an hour to update its command list.

Sample Server Application

#!/usr/bin/env python3
# app.py
import discord_app

from . import app_config

PORT = "8080"

app = discord_app.Application.from_basic_data(
    id=app_config.APPLICATION_ID,
    public_key=app_config.PUBLIC_KEY,
    bot_token=app_config.BOT_TOKEN,
    # Set Discord interaction endpoint URL to http(s)://<YOUR-ADDRESS>:<PORT>/<ENDPOINT>
    endpoint="/api/discord/command"
)

app._flask.testing = True
app._logger.setLevel(logging.DEBUG)


@app.application_command(
    options=discord_app.ApplicationCommand(
        name="version",
        name_localizations={
            "zh-TW": "顯示程式版本"
        },
        type=discord_app.ApplicationCommandType.CHAT_INPUT,
        description="Show application version",
        description_localizations={
            "zh-TW": "顯示程式版本"
        }
    ),
    register_on_change=True  # Register command on specification change or is new command.
)
def show_version(_: discord_app.InteractionRequest) -> discord_app.InteractionResponse:
    return discord_app.InteractionResponse(
        type=discord_app.InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
        data=discord_app.InteractionResponseMessage(
            content="test application/0.0.1"
        )
    )

app.run(
    host="0.0.0.0",
    port=PORT
)
 $ python3 app.py

Links

discord_app's People

Contributors

jacky9813 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.