ConversationMenuControlPanel
Control panel for conversational menus. Can be used to update or close the conversational menu, or to perform manual navigation between conversational menus.
Methods
update
// Overload 1
update(config: { immediate: true }): Promise<void>;
Call this method to update the conversational 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 conversational menu is updated, but note that this will perform the update lazily. A new conversational 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 conversational menu.
Pass { immediate:
to perform the update eagerly instead of lazily. A dedicated API call that updates the conversational menu is sent immediately. In that case, the method returns a Promise that you should await
. Eager updating may cause flickering of the conversational menu, and it may be slower in some cases.
close
// Overload 1
close(config: { immediate: true }): Promise<void>;
Closes the conversational menu. Removes all buttons underneath the message.
Calling this method will guarantee that the conversational menu is closed, but note that this will be done lazily. A new conversational 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 conversational menu.
Pass { immediate:
to perform the update eagerly instead of lazily. A dedicated API call that updates the conversational menu is sent immediately. In that case, the method returns a Promise that you should await
. Eager closing may be slower in some cases.
back
// Overload 1
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:
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
// Overload 1
nav(to: string | { id: string }, config: { immediate: true }): Promise<void>;
Navigates to the specified conversational submenu. The given identifier is the same string that you pass to conversation
. If you did not pass a string, the identifier will be auto-generated and is accessible via menu
. If you specify the identifier of the current conversational menu itself, this method is equivalent to ctx
.
Calling this method will guarantee that the navigation is performed, but note that this will be done lazily. A new conversational 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:
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 conversational menu, and it may be slower in some cases.