discord-interactions-python icon indicating copy to clipboard operation
discord-interactions-python copied to clipboard

Add decorator to register/update slash commands with Discord?

Open alyssadev opened this issue 5 years ago • 0 comments

Would it be in scope for this project to add a decorator to update Discord with changes to slash commands when the flask service is started/reloaded in debug mode for faster development? There would likely need to be some way to store bot token as authentication in the flask app, maybe a wrapper of some kind. as an example:

from discord_interactions import verify_key_decorator, SlashCommand

app = Flask(__name__)
sc = SlashCommand(app)
sc.token = environ["BOT_TOKEN"] # also retrieves application client ID
sc.guild_id = guild_id # optional, limits all commands on this service to a guild, would also be configurable from each decorator

def get_opts(name):
    with open("options.json") as f
        return json.load(f)[name]

@app.route("/", methods=["POST"])
@verify_key_decorator(PUBKEY) # could be implicit with inclusion of SlashCommand.command
@sc.command(name="watch", description=long_desc, options=get_opts("watch")) # , guild_id=guild_id)
def watch():
    pass

If this type of behaviour is not in scope I'll start up a separate project to provide this functionality.

alyssadev avatar Dec 25 '20 16:12 alyssadev