Discord Interaction Application framework for Python
Project description
Discord Interaction Application framework for Python
In early development.
The specification and documentation may change without notification.
Any new ideas are welcomed.
A Flask based Discord Application framework.
System Requirements
- Python 3.9+
- (Recommended) virtualenv
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
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
discord_app-0.0.1a1.tar.gz
(21.2 kB
view details)
Built Distribution
File details
Details for the file discord_app-0.0.1a1.tar.gz
.
File metadata
- Download URL: discord_app-0.0.1a1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.2 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3ed7f6d60a16d7d1b780ac0bcd1c2bc90db010c09e289c5b8f1f9d04ef7c89b |
|
MD5 | c4e93ef24296ef48816b95b5321fa054 |
|
BLAKE2b-256 | 8b4a8ab11d0281b0d6f885b37a9fb251dd726713fa3e82fb9f55419ded76b266 |
File details
Details for the file discord_app-0.0.1a1-py3-none-any.whl
.
File metadata
- Download URL: discord_app-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.2 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9864808728dadbfeb6fccd8947e272d969a79e8d2815739c3ff91ae58584fd5d |
|
MD5 | aa001f01010a44615b75718927a7a01e |
|
BLAKE2b-256 | 4d5c30fb0c70722a76d44c4c9862adb0cf826f67d610eca53d3692aefc14900a |