A Flask extension for Discord slash commands.
Project description
Flask-Discord-Interactions
This is a Flask extension that lets you write Discord Slash Commands using a decorator syntax similarly to Flask's @app.route()
or Discord.py's @bot.command()
.
Usage
Look in the examples directory for more detailed examples.
import os
from flask import Flask
from flask_discord_interactions import DiscordInteractions
app = Flask(__name__)
discord = DiscordInteractions(app)
app.config["DISCORD_CLIENT_ID"] = os.environ["DISCORD_CLIENT_ID"]
app.config["DISCORD_PUBLIC_KEY"] = os.environ["DISCORD_PUBLIC_KEY"]
app.config["DISCORD_CLIENT_SECRET"] = os.environ["DISCORD_CLIENT_SECRET"]
@discord.command()
def ping(ctx):
"Respond with a friendly 'pong'!"
return "Pong!"
discord.set_route("/interactions")
discord.clear_slash_commands(guild_id=os.environ["TESTING_GUILD"])
discord.register_slash_commands(guild_id=os.environ["TESTING_GUILD"])
if __name__ == '__main__':
app.run()
How is this different from discord-py-slash-command
?
Discord.py
and discord-py-slash-command
use a bot user and a websocket to connect to Discord, just like a regular Discord bot. It's a nice way to add support for slash commands to an existing Discord bot, or if you need to use a bot user to manage channels, reactions, etc.
However, for simple bots, using webhooks instead of websockets can let your bot scale better and use less resources. You can deploy a webhook-based bot behind a load balancer and scale it up or down as needed without needing to worry about sharding or dividing up guilds between the app processes.
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
Built Distribution
Hashes for Flask-Discord-Interactions-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1111d0f6c1029991c59b07341e357ed16103fb525b066a313045231d6159c1f |
|
MD5 | ff1cbcdc4b9a28807e21d95fb420a44b |
|
BLAKE2b-256 | 9691e80a72d81b631755fa0c45db42bda7037ceb9b1b86b085258aa64c26a459 |
Hashes for Flask_Discord_Interactions-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33804f769513cdb8190fd06e89b41a8b41fdc3feb9c5c47cce0d7cf479540397 |
|
MD5 | 50fc0df718507ae5598cc29bdf7cbb4a |
|
BLAKE2b-256 | 0e44e9204c1be5d10674f8d7cf9220267e74468ec7d1707e2265a7980533b74a |