breqdev/flask-discord-interactions

how to Use Flask-discord-interactions..?

perymerdeka opened this issue · 2 comments

I'm trying to use this library, but I have trouble using the bot command is a guide / documentation for this library, here is mycode

import os
from dotenv import load_dotenv
from flask import Flask
from flask_discord_interactions import DiscordInteractions

app = Flask(__name__)
discord = DiscordInteractions(app)

# load dotenv
load_dotenv('.env')

# configuration
app.config["DISCORD_CLIENT_ID"] = os.getenv("DISCORD_CLIENT_ID")
app.config["DISCORD_PUBLIC_KEY"] = os.getenv("DISCORD_PUBLIC_KEY")
app.config["DISCORD_CLIENT_SECRET"] = os.getenv("DISCORD_CLIENT_SECRET")

@discord.command()
def ping(ctx):
    "Respond with a friendly 'pong'!"
    return "Pong!"


discord.set_route("/interactions")


if __name__ == '__main__':
    app.run()

Could you share some more information about how you are running the code? That would help me figure out what the issue is here. Are you getting any specific error messages? What are you using to expose the Flask server to the Internet? (Are you using ngrok?) It would help to know with more detail what exactly is happening, and what exactly you expect to happen.

It would also be helpful to know what exactly you are having trouble with. Are you able to set the Interactions URL in the Discord Developer Portal? Do the commands appear in the Discord client?

Also, I noticed your code doesn't call discord.update_slash_commands(). You need to call this function in order to register the slash commands with Discord. You probably want to add discord.update_slash_commands() after the call to discord.set_route(). (You also might want to provide a guild_id parameter with the ID of the server you're using for testing. Otherwise, Discord can take up to an hour to process the slash commands.)

I'm going to close this issue due to inactivity, feel free to reopen it if you have more information that could help narrow down the issue.