【问题标题】:How to set minimum and maximum length of a string argument?如何设置字符串参数的最小和最大长度?
【发布时间】:2022-12-18 22:05:51
【问题描述】:

到目前为止我有这个:

@app_commands.Argument(
  username={
    "min_length": 3,
    "max_length": 22
  }
)
async def inv(interaction:discord.Interaction, username:str):
  # code

但它给了我这个错误:

Traceback (most recent call last):
  File "main.py", line 69, in <module>
    @app_commands.Argument(
TypeError: __init__() got an unexpected keyword argument 'username'

我该怎么做才能使 username 参数的最小和最大长度为 3 和 22。

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    到目前为止我有这个:

    @app_commands.Argument( 用户名={ “最小长度”:3, “最大长度”:22 } ) async def inv(交互:discord.Interaction,用户名:str):

    【讨论】:

    • 这是什么意思?
    猜你喜欢
    • 2021-09-18
    • 2012-04-27
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-30
    相关资源
    最近更新 更多