我在他们按下“是”后将其编辑到下一个问题的消息这是我所有的代码,我自己尝试过但没有用,我该怎么办?
注意:我已经在 nextcord.py 中完成了这个并且我为按钮创建了一个类
class buttons(nextcord.ui.View):
def __init__(self):
super().__init__()
self.ak = ak
self.bot = bot
@nextcord.ui.button(label="yes?", style=nextcord.ButtonStyle.success)
async def yes(self, button: nextcord.Button, interaction: nextcord.Interaction):
aki = ak.Akinator()
while aki.progression <= 80:
await msg.edit(content=q)
msg = await bot.wait_for("message")
try:
q = aki.answer(msg.content.lower())
except ak.InvalidAnswerError as e:
await interaction.response.edit_message(e)
continue
aki.win()
await interaction.send(f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t")
@bot.slash_command(name="guess", description="test")
async def akinator(interaction: nextcord.Interaction):
msg2 = await interaction.send("Akinator is here to guess!")
msg2
view = buttons(buttons.yes)
try:
aki = ak.Akinator()
q = aki.start_game()
msg = await msg2.edit(content=q, view=view)
msg = await bot.wait_for("message")
if msg.content.lower() == "b":
try:
q=aki.back()
except ak.CantGoBackAnyFurther:
await interaction.send(e)
aki.win()
await interaction.send(f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t")
correct = await bot.wait_for("message")
if correct.content.lower() == "y":
await interaction.send("Yay\n")
else:
await interaction.send("Oof\n")
except Exception as e:
await interaction.send(e)