【发布时间】:2021-12-04 07:26:39
【问题描述】:
您好,我正在开发一个不和谐的机器人,我正在尝试添加选择角色作为此命令的参数。它应该看起来像
这是我现在的代码
@bot.slash_command(name = "setrankroles",guild_ids = [898725831164178442])
async def setroles(ctx,
role: Option(discord.Role,"What role are you assigning?"),
rank: Option(str, "What rank goes with that role?", choices=valid_ranks),
):
它会产生这个错误
Traceback (most recent call last):
File "/home/maximummaxx/Documents/Coding/Python/Valorant_dc/main.py", line 205, in <module>
role: Option(discord.Role,"What role are you assigning?"),
File "/home/maximummaxx/Documents/Coding/Python/Valorant_dc/env/lib/python3.9/site-packages/discord/commands/commands.py", line 510, in __init__
to_assign = input_type() if isinstance(input_type, type) else input_type
TypeError: __init__() missing 3 required keyword-only arguments: 'guild', 'state', and 'data'
谢谢
【问题讨论】:
-
图片上传不正确 - 看不到。
-
对我来说很好。试试这个i.imgur.com/5oBNq5R.png
-
valid_ranks 设置为什么?
-
@Lloyd 这是一个字符串列表,例如 [“Bronze”,”Silver”,”Daimond”]
标签: python discord.py pycord