我的目标是链接或链接几个不同的不同的情态-一个接一个,以创建一个连续的形式,因为不允许添加超过5个项目或每个模式的"问题".
目标是让MODEL_1和MODEL_2各有5个问题.用户每次运行命令时,都会显示MODEL_1.完成后,用户将提交MODEL_1,之后将出现MODEL_2.
遗憾的是,我所有的try 都没有成功,Discord在提交第一个模式后没有关闭它,而是返回错误:"有些地方出了问题,请重试".该错误不是代码错误,而是discord模式内部的错误.
下面是一个代码片段来说明我正在做的事情:
class Modal_2(discord.ui.Modal,title="Modal_2"):
question_1 = discord.ui.TextInput(label="That's the second question")
asnyc def on_sumbit(self,interaction:discord.Interaction):
await interaction.response.send_message(content="Thanks for your input")
class Modal_1(discord.ui.Modal,title="Modal_1"):
question_1 = discord.ui.TextInput(label="That's the first question")
asnyc def on_sumbit(self,interaction:discord.Interaction):
await interaction.response.send_modal(Modal_2())
class main(commands.Cog):
def __init__(self,bot):
self.bot = bot
@app_commands.command(name="survey")
async def main(self,interaction:discord.Interaction)
await interaction.response.send_modal(Modal_1())
运行该命令后,将显示第一个模式.虽然提交后,第二个情态不会出现,第一个情态也不会被驳回.在提交后,它只在第一个模式中返回错误:"发生错误,重试",但现在实际的"代码"错误或异常显示在控制台中.