import { MenuRange } from "https://deno.land/x/grammy_menu@v1.2.2/menu.ts";
This is a dynamic way to initialize menu. A typical use case is when you
want to create an arbitrary menu, using the data from ctx.session
:
const menu = new Menu('root')
menu.dynamic(ctx => ctx.session.data.reduce((range, entry) => range.text(entry)), new Menu.Builder())
bot.command("start", async (ctx) => {
await ctx.reply("Menu", {
reply_markup: menu,
});
});
Parameters
rangeBuilder: (ctx: C, range: MenuRange<C>) => MaybePromise<MaybeRawRange<C> | void>
Async menu factory function