Skip to main content
Module

x/grammy_menu/mod.ts>MenuControlPanel

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

Menu control panel. Can be used to update or close the menu, or to perform manual navigation between menus.

Methods

update(config: { immediate: true; }): Promise<void>

Call this method to update the menu. For instance, if you have a button that changes its text based on ctx, then you should call this method to update it.

Calling this method will guarantee that the menu is updated, but note that this will perform the update lazily. A new menu is injected into the payload of the request the next time you edit the corresponding message. If you let your middleware complete without editing the message itself again, a dedicated API call will be performed that updates the menu.

Pass { immediate: true } to perform the update eagerly instead of lazily. A dedicated API call that updates the menu is sent immediately. In that case, the method returns a Promise that you should await. Eager updating may cause flickering of the menu, and it may be slower in some cases.

update(config?: { immediate?: false; }): void
close(config: { immediate: true; }): Promise<void>

Closes the menu. Removes all buttons underneath the message.

Calling this method will guarantee that the menu is closed, but note that this will be done lazily. A new menu is injected into the payload of the request the next time you edit the corresponding message. If you let your middleware complete without editing the message itself again, a dedicated API call will be performed that closes the menu.

Pass { immediate: true } to perform the update eagerly instead of lazily. A dedicated API call that updates the menu is sent immediately. In that case, the method returns a Promise that you should await. Eager closing may be slower in some cases.

close(config?: { immediate?: false; }): void
back(config: { immediate: true; }): Promise<void>

Navigates to the parent menu. By default, the parent menu is the menu on which you called register when installing this menu.

Throws an error if this menu does not have a parent menu.

Calling this method will guarantee that the navigation is performed, but note that this will be done lazily. A new menu is injected into the payload of the request the next time you edit the corresponding message. If you let your middleware complete without editing the message itself again, a dedicated API call will be performed that performs the navigation.

Pass { immediate: true } to navigate eagerly instead of lazily. A dedicated API call is sent immediately. In that case, the method returns a Promise that you should await. Eager navigation may cause flickering of the menu, and it may be slower in some cases.

back(config?: { immediate?: false; }): void
nav(to: string, config: { immediate: true; }): Promise<void>

Navigates to the specified submenu. The given identifier is the same string that you pass to new Menu(''). If you specify the identifier of the current menu itself, this method is equivalent to ctx.menu.update().

Remember that you must register all submenus at the root menu using the register method before you can navigate between them.

Calling this method will guarantee that the navigation is performed, but note that this will be done lazily. A new menu is injected into the payload of the request the next time you edit the corresponding message. If you let your middleware complete without editing the message itself again, a dedicated API call will be performed that performs the navigation.

Pass { immediate: true } to navigate eagerly instead of lazily. A dedicated API call is sent immediately. In that case, the method returns a Promise that you should await. Eager navigation may cause flickering of the menu, and it may be slower in some cases.

nav(to: string, config?: { immediate?: false; }): void