Module

x/grammy/mod.ts>InlineKeyboard#toFlowed

The Telegram Bot Framework.
Very Popular
Go to Latest
method InlineKeyboard.prototype.toFlowed
import { InlineKeyboard } from "https://dotland.deno.dev/x/grammy@v1.18.3/mod.ts";

Creates a new inline keyboard with the same buttons but reflowed into a given number of columns as if the buttons were text elements. Optionally, you can specify if the flow should make sure to fill up the last row.

This method is idempotent, so calling it a second time will effectively clone this inline keyboard without reordering the buttons.

Here are some examples.

original    flowed
[  a  ]  ~> [  a  ]    (4 columns)

            [  a  ]
[a b c]  ~> [  b  ]    (1 column)
            [  c  ]

[ a b ]     [a b c]
[ c d ]  ~> [ d e ]    (3 columns)
[  e  ]

[ a b ]     [abcde]
[  c  ]  ~> [  f  ]    (5 columns)
[d e f]

[a b c]     [  a  ]
[d e f]  ~> [b c d]    (3 colums, { fillLastRow: true })
[g h i]     [e f g]
[  j  ]     [h i j]

Parameters

columns: number

Maximum number of buttons per row

optional
options: FlowOptions = [UNSUPPORTED]

Optional flowing behavior