Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decorator to register/update slash commands with Discord? #4

Open
alyssadev opened this issue Dec 25, 2020 · 0 comments
Open

Add decorator to register/update slash commands with Discord? #4

alyssadev opened this issue Dec 25, 2020 · 0 comments

Comments

@alyssadev
Copy link

alyssadev commented Dec 25, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant