-1
I have a function which handles "/start" which enters into the wizard scene.
  • Now, i have a message with the inline_keyboard with a btn called "redo".
  • When i click on the "redo btn" i want is that it restarts the whole scene means it should start tha wizard again.
I have tried to do this with the redo btn
superWizard.action("redo", (ctx) => {
  ctx.reply("Restarting Session!");
  ctx.session = {};
  ctx.scene.leave();
  ctx.scene.enter("super-wizard");
});

So how can we restart the wizard scene?

I tried this below code too

return ctx.wizard.selectStep(0);

Still this is not working, Below is my full code.

const superWizard = new Scenes.WizardScene(
  "super-wizard",
  (ctx) => {
  ... 
     return ctx.wizard.next();
  },
  (ctx) => { 
   ...
    return ctx.wizard.next();
},
  (ctx) => {
  ...
   return ctx.wizard.next();
  },
  (ctx) => {
      bot.telegram.sendMessage(ctx.chat.id, `Perform Action`, {
        reply_markup: {
          inline_keyboard: [
            [
              { text: "Confirm & Send!", callback_data: "confirm" },
              { text: "Redo!", callback_data: "redo" },
              { text: "Stop!", callback_data: "stop" },
            ],
          ],
        },
      });
    }
  }
);


superWizard.action("redo", (ctx) => {
  ctx.reply("Restarting Session!");
  ctx.session = {};
  ctx.wizard.selectStep(0);
});

Please provide some help.

1 Answers1

0

You can try to do ctx.scene.reenter() instead of ctx.wizard.selectStep(0)

Dev
  • 1
  • Try using code formatting .e.g. `ctx.scene.reenter()`. In case of inline code, surround your text with grave accent symbols, more on markdown [here](https://stackoverflow.com/editing-help) – Abdelrahman Jun 05 '23 at 09:33
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – DSDmark Jun 07 '23 at 10:58