I have this so far:
JavaScript
x
9
1
@app_commands.Argument(
2
username={
3
"min_length": 3,
4
"max_length": 22
5
}
6
)
7
async def inv(interaction:discord.Interaction, username:str):
8
# code
9
But it gives me this error:
JavaScript
1
5
1
Traceback (most recent call last):
2
File "main.py", line 69, in <module>
3
@app_commands.Argument(
4
TypeError: __init__() got an unexpected keyword argument 'username'
5
How do I make it so that the min and max length of the username
argument is 3
and 22
.
Advertisement
Answer
I was able to accomplish this by using app_commands.Range.
JavaScript
1
3
1
async def inv(interaction:discord.Interaction, username:app_commands.Range[str, 3, 22]):
2
# code
3