Skip to main content
Module

x/grammy_menu/mod.ts>MenuRange#submenu

Easily create interactive menus with grammY.
Go to Latest
method MenuRange.prototype.submenu
import { MenuRange } from "https://deno.land/x/grammy_menu@v1.1.2/mod.ts";

Adds a button that navigates to a given submenu when pressed. You can pass in the identifier of another menu instance. This way, you can effectively create a network of menus with navigation between them.

It is necessary that you register the targeted submenu by calling menu.register(submenu). Otherwise, no navigation can be performed. Note that you then don't need to call bot.use(submenu) anymore, all registered submenus will automatically become interactive, too.

You can also navigate to this submenu manually by calling ctx.menu.nav('sub-id'), where 'sub-id' is the identifier of the submenu.

You can call submenu.back() to add a button that navigates back to the parent menu, i.e. the menu at which you registered the submenu.

You can get back the submenu instance by calling parent.at('sub-id'), where 'sub-id' is the identifier you passed to the submenu.

Parameters

text: MaybeDynamicString<C>

The text to display, or a text with payload

menu: string

The identifier of the submenu to open

...middleware: MenuMiddleware<C>[]

The listeners to call when the button is pressed

Parameters

text: TextAndPayload<C>
menu: string
...middleware: MenuMiddleware<C & { match: string; }>[]

Parameters

text: MaybePayloadString<C>
menu: string
...middleware: MenuMiddleware<C>[]