def test_register_options(): app = Flask(__name__) app.config["DONT_VALIDATE_SIGNATURE"] = True app.config["DONT_REGISTER_WITH_DISCORD"] = True discord = DiscordInteractions(app) @discord.command() def ping(ctx, option1: str, option2: float, option3: str = ""): return f"pong" discord.update_commands()
def test_register_subcommand(): app = Flask(__name__) app.config["DONT_VALIDATE_SIGNATURE"] = True app.config["DONT_REGISTER_WITH_DISCORD"] = True discord = DiscordInteractions(app) group = discord.command_group("group") @group.command() def subcommand(ctx): return "pong" discord.update_commands()
def test_register_message_command(): app = Flask(__name__) app.config["DONT_VALIDATE_SIGNATURE"] = True app.config["DONT_REGISTER_WITH_DISCORD"] = True discord = DiscordInteractions(app) @discord.command(type=ApplicationCommandType.MESSAGE) def ping(ctx): return "pong" @discord.command(type=ApplicationCommandType.MESSAGE) def PING(ctx): return "pong" @discord.command(name="user test", type=ApplicationCommandType.MESSAGE) def ping(ctx): return "pong" discord.update_commands()
sys.path.insert(1, ".") import quart.flask_patch from flask_discord_interactions import DiscordInteractions, Message warnings.simplefilter("always", DeprecationWarning) app = Quart(__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.update_commands() # You can now use async functions! @discord.command() async def ping(ctx): "Respond with a friendly 'pong'!" return "Pong!" # Non-async functions still work @discord.command() def pong(ctx): return "Ping!"