所以我创建了一个命令来发送一个带有一些名称的下拉菜单,当使用关键字时
discord.SelectMenu
我在它的关键字中得到一个错误
custom_id
这是代码
@tree.command(name="troops", description="shows list of troops")
async def troops(interaction):
mydb.execute("SELECT name FROM troops")
result = mydb.fetchall()
options = [discord.SelectOption(label=row[0], value=row[0]) for row in result]
menu = discord.SelectMenu(custom_id= "troop_menu", placeholder="select a troop", options=options)
row = discord.ActionRow(menu)
await interaction.response.send_message("Select a troop:", components=[row])
而我得到的错误是
discord.app_commands.errors.CommandInvokeError: Command 'troops' raised an exception: TypeError: SelectMenu.__init__() got an unexpected keyword argument 'custom_id'
此外,我还得到了一个错误,说
Expected 1 more positional argumen
在
custom_id = "troop_menu"