discord-interactions-python
Types and helper functions for Discord Interactions webhooks.
Installation
Available via pypi:
pip install discord-interactions
Usage
Use the InteractionType and InteractionResponseType enums to process and respond to webhooks.
Use verify_key to check a request signature:
if verify_key(request.data, signature, timestamp, 'my_client_public_key'):
print('Signature is valid')
else:
print('Signature is invalid')
Use verify_key_decorator to protect routes in a Flask app:
import os
from flask import Flask, request, jsonify
from discord_interactions import verify_key_decorator, InteractionType, InteractionResponseType
CLIENT_PUBLIC_KEY = os.getenv('CLIENT_PUBLIC_KEY')
app = Flask(__name__)
@app.route('/interactions', methods=['POST'])
@verify_key_decorator(CLIENT_PUBLIC_KEY)
def interactions():
if request.json['type'] == InteractionType.APPLICATION_COMMAND:
return jsonify({
'type': InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
'data': {
'content': 'Hello world'
}
})
Exports
This module exports the following:
InteractionType
An enum of interaction types that can be POSTed to your webhook endpoint.
InteractionResponseType
An enum of response types you may provide in reply to Discord's webhook.
InteractionResponseFlags
An enum of flags you can set on your response data.
verify_key(raw_body: str, signature: str, timestamp: str, client_public_key: str) -> bool:
Verify a signed payload POSTed to your webhook endpoint.
verify_key_decorator(client_public_key: str)
Flask decorator that will verify request signatures and handle PING/PONG requests.
Metadata
Release files for discord-interactions 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| discord-interactions-0.4.0.tar.gz | 3.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| discord_interactions-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / discord-interactions-0.4.0.tar.gz
| Download URL | discord-interactions-0.4.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41bd0289a6460437c7382ec56d99ee604e8cb15259f2d831ae1d248709f8bcb2
|
|
BLAKE2b-256 checksum How to use checksums |
9f610fb857ffcbc9a0a946caf0a50874f80ba98798ca583ba59f7f34e22912c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/2.7.18 Darwin/20.6.0
|
Release files / discord_interactions-0.4.0-py3-none-any.whl
| Download URL | discord_interactions-0.4.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc8dcac17873a5bf0b065967b109fabf626a02fe21226369a13e1ee2a6bcd833
|
|
BLAKE2b-256 checksum How to use checksums |
deef21bb4be7e589c038bd0d73b6be53e045daaf785b4cbb6c6db3dabab810ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/2.7.18 Darwin/20.6.0
|
Security for discord-interactions 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.