pythondiscorddiscord-interactions

The application did not respond discord interactions


I'm getting the "The application did not respond" error

@slash_command(name="rpc", description="Rock Paper Scissors")
@slash_option(
    name="player",
    description="You're Choice",
    required=True,
    opt_type=OptionType.STRING,
    choices=[
        SlashCommandChoice(name="Rock", value="0"),
        SlashCommandChoice(name="Paper", value="1"),
        SlashCommandChoice(name="Scissors", value="2")
    ]
)
async def rpc_function(ctx: SlashContext, player: str):
    bot = random.randint(0,2)
    options = ["Rock", "Paper", "Scissors"]
    if (player == bot):
        # TIE
        await ctx.send(f"We both choose **{options[bot]}**, Tied")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 0 and bot == 1):
        # BOT WON / ROCK - PAPER
        await ctx.send(f"I choose **{options[bot]}** so I WON")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 0 and bot == 2):
        # PLAYER WON / ROCK - SCISSORS
        await ctx.send(f"You won cuz I choose **{options[bot]}**")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 1 and bot == 0):
        # PLAYER WON / PAPER - ROCK
        await ctx.send(f"YOU WON, I choose **{options[bot]}**")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 1 and bot == 2):
        # BOT WON / PAPER - SCISSORS
        await ctx.send(f"HEHE I WON CUZ I CHOOSE **{options[bot]}**")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 2 and bot == 0):
        # BOT WON / SCISSORS - ROCK
        await ctx.send(f"I won, I choose {options[bot]}")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])
    elif (player == 2 and bot == 1):
        # PLAYER WON / SCISSORS - PAPER
        await ctx.send(f"You won cuz I choose {options[bot]}")
        print([datetime.datetime.now().strftime("%x %X")] ,[ctx.author.username]," Used /rpc player=",options[player], "bot=", options[bot])

It's a discord bot using interactions.py and this is a command for rock paper scissors game I'm running my bot in my pc


Solution

  • Solved the issue

    @slash_option(
        name="player",
        description="You're Choice",
        required=True,
        opt_type=OptionType.STRING, --> opt_type=OptionType.INTEGER,
        choices=[
            SlashCommandChoice(name="Rock", value="0"),
            SlashCommandChoice(name="Paper", value="1"),
            SlashCommandChoice(name="Scissors", value="2")
        ]
    )