I have 2 commands: test
and send_arg
. During the execution of the test
command, it becomes necessary to receive data from the send_arg
command.
I'm waiting for the send_arg
command to be called via wait_for
, and I pass the context to test
to get the argument passed to send_arg
.
But when I try to get the selected_options
property, I get an error.
AttributeError: 'ApplicationContext' object has no attribute 'selected_options'
At the same time, looking at the documentation, I was convinced that such a property definitely exists.
import discord
from discord.ext import commands
from discord.commands import Option
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.slash_command()
async def send_arg(ctx, arg: Option(str, choices=['var1', 'var2', 'var3'], required=True)):
pass
@bot.slash_command()
async def test(ctx):
def check(context):
return context.author == ctx.author
app_cmd_ctx = await bot.wait_for('application_command', check=check)
print(app_cmd_ctx.selected_options)
bot.run(TOKEN)
py-cord version:
pip install py-cord==2.0.0b1
ApplicationContext.selected_options
does not exist in pycord versions before version 2.0 beta 5.
To fix your error, you can either update pycord to this version using pip install git+https://github.com/Pycord-Development/pycord
.
If you need to use version 2.0 beta 1 or any other version prior to beta 5, you can replace ApplicationContext.selected_options
with the following code:
ApplicationContext.interaction.data.get("options", None)